Forum Discussion

StuartSmith's avatar
StuartSmith
Power Participant
5 years ago
Solved

Pie Chart: Positive Values vs Negative Values

I have a Measured column that shows the variance between 2 columns..

 

Measure: Headcount vs Laptops Difference = LAPTOPS[Stock_Count_Measure] - Headcount[Headcount_Measure]
 
This coulmn will then contain either Negative, Positive or "0" values. 
 
Whats the best way to get a pie chart to count and display the number of Positive, Negative and "0" values.
 
 
  • Pragati11's avatar
    Pragati11
    5 years ago

    Hi StuartSmith ,

     

    You can do a caluclation as follows:

    NegaticveCnt = CALCULATE(DISTINCTCOUNT(tablename[Country]), tablename[GroupCol] = "Negative")

     

    Do similar measures for Positive and 0.

     

    Thanks,

    Pragati

4 Replies

  • Hi StuartSmith ,

     

    You can try created a calculated column as follows to use on pie-chart:

    GroupCalc = IF([Measure] = 0, "0 Values", IF([Measure] > 0, "Positive Values", "Negative Values"))

     

    Replace [Measure] in above DAX with your measure/column.

     

    Thanks,

    Pragati

    • StuartSmith's avatar
      StuartSmith
      Power Participant

      Thanks, your measure worked great, but then reaslied the result wasnt exactly what I wanted.  I now have a table similar to the below

       

      The chart is then conting each row, so Negative = 2, Positive = 2 & 0 = 1, but I realised that I need it to count each distinct country, so Negative = 1 (UK) , Positive = 1 (France) & 0 = 2 (Germany & Spain).

       

      I am trying "DistinctCount" with your measure, but can figure it out.  Hope that makes sense.

      • Pragati11's avatar
        Pragati11
        Super User

        Hi StuartSmith ,

         

        You can do a caluclation as follows:

        NegaticveCnt = CALCULATE(DISTINCTCOUNT(tablename[Country]), tablename[GroupCol] = "Negative")

         

        Do similar measures for Positive and 0.

         

        Thanks,

        Pragati

  • StuartSmith ,
    I replicated some sample at my end as per your deets.

    SO create first one calculated column:

    Category Column =
    VAR Diff = TblName[Stock Count Measure] - TblName[Headcount Measure]
    RETURN SWITCH(TRUE(),Diff>0,"Positive",
    Diff<0,"Negative",
    Diff=0,"0 Values")

    Then create measure like below:
    Count Measure = COUNT(TblName[Category Column])
    Then you can put these on pie chart like the attached screen shot: