Forum Discussion
IF Statement Total Not Summing Correctly Correctly In Measure
- 1 year ago
Hi alee5210 - Instead of using the row-level logic directly in the measure, you can aggregate the logic using SUMX. This will apply the IF condition for each group and then sum the results.
Overall =
SUMX (
SUMMARIZE (
data,
data[GroupField1],
data[GroupField2],
"DistCountA", CALCULATE ( DISTINCTCOUNT ( data[SaleA] ) ),
"DistCountB", CALCULATE ( DISTINCTCOUNT ( data[SaleB] ) ),
"DistCountC", CALCULATE ( DISTINCTCOUNT ( data[SaleC] ) )
),
IF ( [DistCountA] = 1 && [DistCountB] = 1 && [DistCountC] = 1, 1, 0 )
)try the above logic and i hope it works
Hi alee5210 - Instead of using the row-level logic directly in the measure, you can aggregate the logic using SUMX. This will apply the IF condition for each group and then sum the results.
Overall =
SUMX (
SUMMARIZE (
data,
data[GroupField1],
data[GroupField2],
"DistCountA", CALCULATE ( DISTINCTCOUNT ( data[SaleA] ) ),
"DistCountB", CALCULATE ( DISTINCTCOUNT ( data[SaleB] ) ),
"DistCountC", CALCULATE ( DISTINCTCOUNT ( data[SaleC] ) )
),
IF ( [DistCountA] = 1 && [DistCountB] = 1 && [DistCountC] = 1, 1, 0 )
)
try the above logic and i hope it works
This is exactly what I was after. I still need to do some additional testing, but will this recalculate based on any slicers applied? E.g. If I filter data to a single store, or if there was an additional date field that I then filtered to be between a specific range, would this still work and be effective?