Comparison Any Year to Any Year

Hello,

How do I compare a given year with any year through slicer? Something about disconnected tables, but I can’t get my head wrapped around that.

I have created basic YTD and PYTD formulas which works fine.

But users are looking to compare any year with any year through slicer.

Basically I created 6 formulas after seeing Sam’s videos: 3 for YTD and 3 for PYTD:

  1. Setup formula
  2. Virtual Table
  3. As the total was not showing up in the card then another virtual table.

This is for YTD and below is PYTD.

YTD Formulas:

1. YTD Sales Demand Setup = 

VAR CurrentDay =  SELECTEDVALUE( 'Date'[DAY_NAME])
VAR CurrentWeek = SELECTEDVALUE( 'Date'[FISCAL_WEEK] )
VAR CurrentYear = SELECTEDVALUE( 'Date'[FISCAL_YEAR] )
RETURN
CALCULATE ( [Sales Demand],
	FILTER ( ALL( 'Date' ),
		'Date'[FISCAL_WEEK]= CurrentWeek  && [DAY_NAME] = CurrentDay &&'Date'[FISCAL_YEAR] = CurrentYear))

2. YTD Sales Demand = 
SUMX (
    SUMMARIZE (
        'Date',
        'Date'[FISCAL_YEAR],
        'Date'[DAYS_IN_FISCAL_WEEK],
        'Date'[DAY_NAME],
        "YTD Sales", [YTD Sales Demand Setup] 
    ),
    [YTD Sales]
)

3. YTD Sales Demand Cumulative = 
SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( 'Date', 'Date'[FISCAL_YEAR], 'Date'[FISCAL_WEEK],'Date'[DAY_NAME], "@CY Sales", [YTD Sales Demand] ),
        "ABC", [@CY Sales]
    ),
    [@CY Sales]
)

PYTD:

1. PYTD Sales Demand Setup = 
VAR CurrentDay =  SELECTEDVALUE( 'Date'[DAY_NAME])
VAR CurrentWeek = SELECTEDVALUE( 'Date'[FISCAL_WEEK] )
VAR CurrentYear = SELECTEDVALUE( 'Date'[FISCAL_YEAR] )

RETURN
CALCULATE( [Sales Demand],
    FILTER( ALL( 'Date' ),
		'Date'[FISCAL_WEEK]= CurrentWeek && [DAY_NAME] = CurrentDay &&'Date'[FISCAL_YEAR] = CurrentYear - 1))


2. 
PYTD Sales Demand = 
SUMX (
    SUMMARIZE (
        'Date',
        'Date'[FISCAL_YEAR],
        'Date'[DAYS_IN_FISCAL_WEEK],
        'Date'[DAY_NAME],
        "LY Sales", [PYTD Sales Setup]
    ),
    [LY Sales]
)


3. PYTD Sales Demand Cumulative = 
SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( 'Date', 'Date'[FISCAL_YEAR], 'Date'[FISCAL_WEEK],'Date'[DAY_NAME], "@LY Sales", [PYTD Sales Demand] ),
        "ABC", [@LY Sales]
    ),
    [@LY Sales]
)

So in below picture, I want to populate whatever is selected through the “Comparison Year” slicer instead of PY numbers.

Now my question is how do I make this as dynamic so I can compare to any year?

Thanks,
RK

Hi @rit372002,

You can refer to this article or provide a sample PBIX if you require more assistance.

I hope this is helpful

Thanks for working on a solution on this post @Melissa.

Hello @rit372002, did the response above solve your query?

Please don’t forget if your question has been answered within the forum it is important to mark your thread as ‘solved’

Hi @Melissa ,

I think I got a solution but it was too easy so I still need to see if there are any gotchas.

Here are the steps if anyone else is interested:

  1. Created a disconnect YEAR table.

image

  1. In PYTD Setup formula: did this:

  1. Now whenever I do my comparison year, it calculates it correctly.

Does it make sense? I find it too easy of a solution.

Thanks for your help,
-RK