Forum Discussion

TM_'s avatar
TM_
Frequent Visitor
1 year ago
Solved

Cannot Distinct Count Negative Values

Hello.   Unsure what the issue is here - I created a measure to find the difference between two sets of values ('A' and 'B' for simplicity):   Difference =  IF(ISBLANK(A),  BLANK(),  (A- B)) ...
  • Bibiano_Geraldo's avatar
    1 year ago

    Hi TM_ ,

    You can use the bellow DAX measure to achieve your goal:

    CategoryOutperformance = 
    CALCULATE(
        DISTINCTCOUNT('Test2'[Category]),
        FILTER(
            ADDCOLUMNS(
                VALUES('Test2'[Category]),
                "Difference",
                VAR A = CALCULATE(SUM('Test2'[Value]), 'Test2'[Subcategory] = "A")
                VAR B = CALCULATE(SUM('Test2'[Value]), 'Test2'[Subcategory] = "B")
                RETURN IF(ISBLANK(A), BLANK(), A - B)
            ),
            [Difference] < 0
        )
    )
    

     

    Your output should look like this: