Forum Discussion
Power BI - way to count rows based on conditional formatting
- 1 year ago
Hi Flossiebug
As per my understanding of you requirement i have tried using below dax.
1. Create a calculated column using below dax ( If you want to add some more condition then you can in to that).CancellationCategory =SWITCH(TRUE(),SEARCH("ill", 'Table'[Reason], 1, 0) > 0, "Illness",SEARCH("medication", 'Table'[Reason], 1, 0) > 0, "Medication Issue","Other")2. Create measure and then add that measure into the card and the calculated column use it as a slicer.
------> Use below dax to create dax which calculate as per the slicer.Count =COUNTROWS('Table')
If this answers your questions, kindly accept it as a solution and give kudos.
Flossiebug Create a new measure in Power BI that counts the number of cancellations for a specific reason. You can use the DAX COUNTROWS function combined with a FILTER function to achieve this.
Illness Cancellations = COUNTROWS(FILTER('YourTableName', 'YourTableName'[CancellationReason] = "Illness"))
Once you have created measures for each reason, you can add a card visualization to your Power BI report canvas. Drag the measure you created (e.g., Illness Cancellations) to the "Values" field of the card visualization to display the quantitative value for each reason.
Hi - thanks for your response. I've gone with a different solution, but can see how yours would help too. Thanks so much for your time and reply.