Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

updated title: Using 2 slicers, comparing only the max value from two range of dates & when max was

Hi,   UPDATE:  I had to updae this post cuz my orginal was confusing.... Hope I've made it clearer....   Need help (again).....   I am using this slicer setup: https://www.sqlbi.com/articles/f...
  • AllisonKennedy's avatar
    6 years ago

    Anonymous 

     

    @mikelee1701
    Not sure this will work with the YEAR listed in your Excel desired result screenshot, but following the same pattern as the formula in the blog link you posted, you can try to create this for max previous value:

    MaxPrevious=
    CALCULATE (
    MAX(table[value]),
    ALL ( 'Date' ),
    USERELATIONSHIP ( 'Date'[Date], 'Previous Date'[Date] )
    )

     

    And this for the Max previous date: 

    Previous Date = CALCULATE([Current Date], ALL('Date'), USERELATIONSHIP( 'Date'[Date], PreviousDate[Date]))
     
    Where this is the 'Current' date (you can give it a better name, but basically using the main date selection filter):
    Current Date =
    VAR MaxValue = [Current Max]
    RETURN
    MAXX(FILTER('Table', 'Table'[Value] = MaxValue), 'Table'[Date])
    *UPDATE: Note this current date measure is different to what is in the attached report - the attached report is INCORRECT. Please use the above syntax instead. 
    Current Max = MAX('Table'[Value])
     
    And YoY is just the difference divided: 
     
    YoY = DIVIDE([Current Max]-[Previous Max], [Previous Max])
     
    The challenge is in formatting the visual, so are you flexible with how it looks? See attached example; below signature.