Forum Discussion

elkjoperik's avatar
elkjoperik
Helper II
7 years ago
Solved

IF filter value does not exist, then use other values

Hi! I have a problem I have not found any solutions to.    I've made a dynamic this week vs last week metric;   Sales PW = VAR CurrentWeek = SELECTEDVALUE(Date[Week Nr]) VAR CurrentYear = SELE...
  • v-jiascu-msft's avatar
    v-jiascu-msft
    7 years ago

    Hi elkjoperik,

     

    There is a solution. Please refer to the file in the attachment. You need to rebuild the model. It's hard to filter the proper data in the model in which all the data is stored in one table. 

    Solution =
    VAR lastweekTotal =
        CALCULATE (
            SUM ( LW_DUMMY[Revenue FY] ),
            FILTER (
                ALL ( 'Calendar' ),
                'Calendar'[WeekNum]
                    = MIN ( 'Calendar'[WeekNum] ) - 1
            )
        )
    RETURN
        IF (
            ISBLANK ( lastweekTotal ),
            CALCULATE (
                SUM ( LW_DUMMY[Revenue FY] ),
                FILTER (
                    ALL ( 'Calendar' ),
                    'Calendar'[WeekNum]
                        = MIN ( 'Calendar'[WeekNum] ) - 1
                ),
                ALL ( Segments )
            ),
            lastweekTotal
        )
    

    IF-filter-value-does-not-exist-then-use-other-values

    Best Regards,
    Dale