Forum Discussion

AB174's avatar
AB174
Regular Visitor
4 years ago
Solved

Require some help with a DAX formula

Hello everyone,

 

I'm extremely new to the DAX and coding world and I'm not sure what formula to use for the result i'm after so bear with me while I try to explain this!. 

 

I'm trying to create a simple pie chart showing the overall percentage of positive and negative outcomes of a survey. All the numbers that are "1 or 2" need to come back as negative and "3 or 4" to come back as positive. Im trying to do this across 8 columns and 22 rows as shown in the image below but can't figure out how to do so. Is there a way to do this?

 

I've also attached an image of how id like the outcome to look like just for a reference if what I said didnt really make sense!

 

Apologies if i'm in the wrong section or haven't made much sense!

 

Many thanksThis is the table i havethe outcome that im after

  • Hi AB174 

     

    Download sample PBIX file

     

    If you use Power Query to Unpivot the table you end up with 2 columns (see my file for details)

     

    You can then write 2 measures to count the 'positive' and 'negative' values

     

    Positive = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', 'DataTable'[Value] > 2 ))

     

     

     

    Negative = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', 'DataTable'[Value] < 3 ))

     

     

    Add these measures to your Donut chart

     

    Regards

     

    Phil

1 Reply

  • Hi AB174 

     

    Download sample PBIX file

     

    If you use Power Query to Unpivot the table you end up with 2 columns (see my file for details)

     

    You can then write 2 measures to count the 'positive' and 'negative' values

     

    Positive = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', 'DataTable'[Value] > 2 ))

     

     

     

    Negative = CALCULATE(COUNTROWS('DataTable'), FILTER('DataTable', 'DataTable'[Value] < 3 ))

     

     

    Add these measures to your Donut chart

     

    Regards

     

    Phil