Forum Discussion
Anonymous
4 years agoNot applicable
sum with condition
Hi all I made this measure Mov_cond_PK = sumx(values(Tabella[Product Number]),if([Initial_PK_2]>0,sum(Tabella[moving_PK]),0)) If I put this measure in a matrix (see below), the figures per...
- 4 years ago
See if this works:
Mov_cond_PK = SUMX ( VALUES ( Tabella[Product Number] ), IF ( [Initial_PK_2] > 0, CALCULATE ( SUM ( Tabella[moving_PK] ) ), 0 ) )Without the CALCULATE, there is no context transition performed, which means the sum of [moving_PK] is done over all the product numbers in the current filter context rather than just the product number from the row context of the SUMX iterator.
If you define SUM ( Tabella[moving_PK] as a measure SumMovingPK, then you don't have to worry about including the extra CALCULATE (since it's included implicitly) and you can write
Mov_cond_PK = SUMX ( VALUES ( Tabella[Product Number] ), IF ( [Initial_PK_2] > 0, [SumMovingPK] ) ), 0 ) )
SpartaBI
4 years agoCommunity Champion
Anonymous
Ok, It's not the lowest granularity of your table. You need context transition.
Did you try AlexisOlson proposal?
Anonymous
4 years agoNot applicable