Forum Discussion
elkjoperik
7 years agoHelper II
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...
- 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 )Best Regards,
Dale
Anonymous
7 years agoNot applicable
Getting an error trying to download your file. Please update the link.
v-jiascu-msft
7 years agoMicrosoft Employee
Hi Anonymous,
I'm glad it helps. Please try this upgraded formula that will respond to the year slicer. You can download the file from https://1drv.ms/u/s!ArTqPk2pu-BkhBLE5poCyLQsDBnQ.
Solution 2 =
VAR lastweekTotal =
CALCULATE (
SUM ( LW_DUMMY[Revenue FY] ),
FILTER (
ALL ( 'Calendar'[WeekNum] ),
'Calendar'[WeekNum]
= MIN ( 'Calendar'[WeekNum] ) - 1
)
)
RETURN
IF (
ISBLANK ( lastweekTotal ),
CALCULATE (
SUM ( LW_DUMMY[Revenue FY] ),
FILTER (
ALL ( 'Calendar'[WeekNum] ),
'Calendar'[WeekNum]
= MIN ( 'Calendar'[WeekNum] ) - 1
),
ALL ( Segments )
),
lastweekTotal
)
Best Regards,
Dale