Forum Discussion
How to select multiple values from filter and create condition base calculated field.
- 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.
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.
Hi v-janeyg-msft
Thank you for your time. Let me check your formula at my end ,will get back to you.