Forum Discussion
eagleae
4 years agoFrequent Visitor
Disconnected tiem slicer
Hi,
I need to compare net sales by two disconnected periods - choose one period in 1st period and second in 2nd period
How can i compare my sales by two disconnected period, choosing it in slicer?
Thanks!
- Anonymous4 years ago
HI eagleae,
You can write the DAX formula to extract the selection and write sub-expressions with these date ranges as conditions to calculate.
formula = VAR selector1 = VALUES ( Table1[Date] ) VAR selector2 = VALUES ( Table2[Date] ) RETURN CALCULATE ( SUM ( Fact[Sales] ), FILTER ( ALLSELECTED ( Fact ), [Date] IN selector1 ), VALUES ( Fact[Category] ) ) - CALCULATE ( SUM ( Fact[Sales] ), FILTER ( ALLSELECTED ( Fact ), [Date] IN selector2 ), VALUES ( Fact[Category] ) )Regards,
Xiaoxin Sheng
1 Reply
- AnonymousNot applicable
HI eagleae,
You can write the DAX formula to extract the selection and write sub-expressions with these date ranges as conditions to calculate.
formula = VAR selector1 = VALUES ( Table1[Date] ) VAR selector2 = VALUES ( Table2[Date] ) RETURN CALCULATE ( SUM ( Fact[Sales] ), FILTER ( ALLSELECTED ( Fact ), [Date] IN selector1 ), VALUES ( Fact[Category] ) ) - CALCULATE ( SUM ( Fact[Sales] ), FILTER ( ALLSELECTED ( Fact ), [Date] IN selector2 ), VALUES ( Fact[Category] ) )Regards,
Xiaoxin Sheng