Forum Discussion
IF filter value does not exist, then use other values
- 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
Hi elkjoperik,
Can you share a dummy sample? Then I can write down the DAX formula.
Best Regards,
Dale
Hi Dale,
Thanks for your reply and time.
I've made a dummy setup (replaced data), but the setup is identical to my orginal setup
You can find it here
In this dummy sample, the "Sales PW" (sales past week) is not affected by the "Segment" filter.
But what I want is when I select the filter "segment", I want it to select the current SKUs, but ignore the current segment when it comes to find the revenue last week from the segment.
- v-jiascu-msft7 years agoMicrosoft Employee
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- elkjoperik7 years agoHelper II
WOW! That worked epic!
Just one thing, I also have a YEAR filter, how would I integrate that into this formula ? Because now the formula gets the right week, but it takes sales from all years and not selected year
- elkjoperik7 years agoHelper II
I also can't download the file you've attached
- Anonymous7 years agoNot applicable
Getting an error trying to download your file. Please update the link.
- v-jiascu-msft7 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