Forum

Power BI - DAX Coun...
 
Notifications
Clear all

Power BI - DAX Count Measure works for card but not for KPI

2 Posts
2 Users
0 Reactions
130 Views
(@rickert)
Posts: 7
Active Member
Topic starter
 

So I have a weird problem. I'm trying to count the number of rows that contain a 'Yes' in the column called 'Behavioral' in a Power BI table that has been uploaded from an Excel table. The measure is as follows:

SafetyBehavioralNMTotal = IF(ISBLANK(CALCULATE(COUNT( SafetyIncidentLog[Behavioral?]), SafetyIncidentLog[Behavioral?]="Yes")), 0,CALCULATE(COUNT( SafetyIncidentLog[Behavioral?]), SafetyIncidentLog[Behavioral?] ="Yes"))

So in other words, if no 'Yes' is found in the column 'Behavioral', then the COUNT function returns a blank; I handle that with a 0. Otherwise, the measure will return the number of rows containing 'Yes' in column 'Behavioral'.

To clarify, a drop down box is used to select the value of 'No' or 'Yes' in the Behavioral column (from within Excel prior to import into Power BI); the default is null or blank.

For a Power BI Card visual, this measure returns the correct result of 1. In the KPI, the SAME measure returns a blank and therefore a 0.

Any clues why the measure works two different ways depending on the type of visual? Really really weird and FRUSTRATING!! 🙂

I have reviewed that table and its data backwards and forwards until my eyes are crossed. There is only one row with 'Yes' in the Behavioral column; the rest of the rows contain 'No' or null. I'm assuming that Excel has null or empty values in columns unless you specifically enter a blank.

 
Posted : 26/01/2023 4:16 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Valerie,

It's very difficult to follow without a sample file. The KPI visuals require a date dimension, so maybe you haven't given it enough information.

Mynda

 
Posted : 26/01/2023 7:42 pm
Share: