Forum Discussion

eagleae's avatar
eagleae
Frequent Visitor
4 years ago
Solved

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!

 

 

  • Anonymous's avatar
    Anonymous
    4 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

  • Anonymous's avatar
    Anonymous
    Not 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