Forum Discussion

wbhite's avatar
wbhite
Icon for Helper I rankHelper I
3 years ago
Solved

How to get variance based on two date slicers

Hello all, I have a report where I need to show a variance based on selections in two date slicers.  See screenshot.  I have a single fact table connected to a date table.  That single date table is...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi wbhite ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data. 

    Fact table:

    Calendar table:

    CALENDAR = CALENDAR(DATE(2023,1,1),DATE(2023,12,31))

    (2) We can create a table and a measure. 

    CALENDAR Table2 = VALUES('CALENDAR'[Date #1])

    Material cost = 
    var _a=CALCULATE(MAX('Fact Table'[total material cost]),FILTER(ALL('Fact Table'),'Fact Table'[date]=SELECTEDVALUE('CALENDAR'[Date #1])))
    var _b=CALCULATE(MAX('Fact Table'[total material cost]),FILTER(ALL('Fact Table'),'Fact Table'[date]=SELECTEDVALUE('CALENDAR Table2'[Date #2])))
    return _b-_a

    (3) Then the result is as follows.

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.