Forum Discussion

alee5210's avatar
alee5210
Helper II
1 year ago
Solved

IF Statement Total Not Summing Correctly Correctly In Measure

Hi All, I'm trying to create an IF statement that has the condition, followed by a 1 or 0 that will sum. My data looks like the following BUT I only have GroupField1/2 and SaleA/B/C. The other colum...
  • rajendraongole1's avatar
    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