Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Having a dynamic flag depending on selected date

Hi,   I'm new at Power BI and got asked to solve a task my co-worker has.   The data model is for a restaurant chain that wants to be able to compare different locations, years and months with a ...
  • Anonymous's avatar
    Anonymous
    5 years ago
    // Create a filtering measure that
    // will return 1 for the restaurants
    // you want to see and 0 otherwise.
    // Then, when you display your restaurants
    // in a table or matrix, just put this
    // measure in the Filter Pane of the visual
    // and set the "is" condition to 1.
    
    [Show Restaurant?] =
    IF( ISINSCOPE( Venue[Restaurant] ),
        var OpenDate = SELECTEDVALUE( Venue[OpeningDate] )
        var ComparisonYear = SELECTEDVALUE( CompareYear[CompareYear] )
        var BaseMonthNumber = MONTH( MIN( 'Date Table'[Date] ) )
        var CutoffDate = DATE( ComparisonYear, BaseMonthNumber, 1 )
        var ShouldShow = OpenDate < CutoffDate
        return
            INT( ShouldShow )
    )