Forum Discussion

Uzi2019's avatar
Uzi2019
Community Champion
5 years ago
Solved

How to select multiple values from filter and create condition base calculated field.

Hi Experts,   I want to do calculation based on filter selection. If user select "TW" the "new " should  display "3700" and if user select "Travel" the "new " should display "1200" or otherwise " O...
  • v-janeyg-msft's avatar
    v-janeyg-msft
    5 years ago

    Hi, Uzi2019 

     

    It’s my pleasure to answer for you.

    According to your description, Do you want to calculate the sum of the values when a date contains multiple products.

    You can try like this:

    Measure =
    VAR p =
        ALLSELECTED ( 'product' )
    RETURN
        SUMX (
            SUMMARIZE (
                'product',
                'product'[Date],
                "test",
                    VAR e = [Date]
                    VAR a =
                        ADDCOLUMNS (
                            p,
                            "value", SWITCH ( [product], "Travel", [Travel], "TW", [TW], 1000 )
                        )
                    VAR b =
                        SUMMARIZE (
                            a,
                            'product'[Date],
                            "sum", SUMX ( FILTER ( a, [Date] = EARLIER ( 'product'[Date] ) ), [value] )
                        )
                    RETURN
                        SUMX ( FILTER ( b, [Date] = e ), [sum] )
            ),
            [test]
        )

    If it doesn’t solve your problem, please feel free to ask me.

     

    Best Regards

    Janey Guo

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.