Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Anonymous
Not applicable

Create a custom measure based on matrix

I have the following matrix:

 

Screenshot 2022-03-14 155837.png

 

What I want is to get the following calculation as a number (%):

Calc = (Count of Promoter - Count of Detractor)/Total (%)

 

How do I do this, to display it as a card?

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous try this:

 

Total Count = COUNTROWS ( YourTable  )

Calc = 
DIVIDE (
   CALCULATE ( [Total Count], YourTable[NPS_Segment] = "Promoter" ) -
   CALCULATE ( [Total Count], YourTable[NPS_Segment] = "Detractor" ),
   [Total Count]
)

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

12 REPLIES 12
parry2k
Super User
Super User

@Anonymous weird, are you ok to share the pbix file, remove any sensitive information before sharing, just keep the basic data.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Ok this is completely my mistake - I had two tables named very similarly and I was mixing up the values from each one.

 

Your solution works just fine now that this has been sorted!! Thank you for your patience

parry2k
Super User
Super User

@Anonymous when you added this measure and visualize in the card, you are not getting correct result? Can you confirm?

 

CALCULATE ( [Total Count], 'NPS_Redeemers'[NPS_SEGMENT] = "Promoter" ) 


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Exactly, adding that as a measure should theoretically give me row 1 of the matrix in the question (i.e. 5402) but it gives me 397

parry2k
Super User
Super User

@Anonymous then it should work, what is TOTAL COUNT? Is it a measure? What is the expression for this measure?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Yes, I created Total Count as a measure as specified in your first reply 

Total Count = COUNTROWS ( Table  )

 which if I visualise it in a card, it gives the correct number (7957). The problem seems to be in the calculations within the DIVIDE

parry2k
Super User
Super User

@Anonymous the formula I gave you, how you try to visualize it? In a card visual?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Yes, in a card

parry2k
Super User
Super User

@Anonymous Can you post sample raw data in the table format? It has something to do with the data structure.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Here is some sample data - note that MSISDN contains unique customer IDs

 

MSISDN  NPS_SEGMENT

123          Detractor

234          Passive

345          Promoter

456          Promoter

567          Detractor

parry2k
Super User
Super User

@Anonymous try this:

 

Total Count = COUNTROWS ( YourTable  )

Calc = 
DIVIDE (
   CALCULATE ( [Total Count], YourTable[NPS_Segment] = "Promoter" ) -
   CALCULATE ( [Total Count], YourTable[NPS_Segment] = "Detractor" ),
   [Total Count]
)

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thanks for the repy @parry2k . However, the calculation doesn't seem correct. It doesn't give me the expected result (expected output = 46.07%, actual output = 2.98%).

I checked, and for example each calculation within the divide does not give me the correct value. For example, 

CALCULATE ( 'NPS_Redeemers'[Total Count], 'NPS_Redeemers'[NPS_SEGMENT] = "Promoter" ) evaluate to 397 when it should actually just be equal to the Count of Promoter from the matrix, i.e. 5402.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.