Forum Discussion
auron
3 years agoNew Member
SUM function with multiple condition
Dear all, i have a table like this one: id price requested 123 150 TRUE 123 150 TRUE 456 100 TRUE 456 100 TRUE 789 200 TRUE 789 200 TRUE 484 350 TRUE 159 ...
- 3 years ago
Hi auron ,
Try the following code:
Total = SUMX ( SUMMARIZE ( FILTER ( 'Table', 'Table'[requested] = "TRUE" ), 'Table'[id], 'Table'[price] ), 'Table'[price] )Be aware that if you have different values for the price in each ID you get the value twice depending on the option you need you may need to adjust this to the following:
Total = SUMX ( SUMMARIZE ( FILTER ( 'Table', 'Table'[requested] = "TRUE" ), 'Table'[id], "MAXIMUMPRICE", MAX ( 'Table'[price] ) ), [MAXIMUMPRICE] )You can then adjust the MAX to minimum, average whatever value you need if the prices are different.
MFelix
3 years agoSuper User
Hi auron ,
Try the following code:
Total =
SUMX (
SUMMARIZE (
FILTER ( 'Table', 'Table'[requested] = "TRUE" ),
'Table'[id],
'Table'[price]
),
'Table'[price]
)
Be aware that if you have different values for the price in each ID you get the value twice depending on the option you need you may need to adjust this to the following:
Total =
SUMX (
SUMMARIZE (
FILTER ( 'Table', 'Table'[requested] = "TRUE" ),
'Table'[id],
"MAXIMUMPRICE", MAX ( 'Table'[price] )
),
[MAXIMUMPRICE]
)
You can then adjust the MAX to minimum, average whatever value you need if the prices are different.