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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Need help For DAX comman regarding calculation in measurement and column

Hi, I have Issued so basically this is just sample data

Here I have to count which ones are the warning and non- warnings basically I have the granularity of data on a daily basis for 12 months so the first thing I do is create measurements to see which ones are categorized as warning and non-warning but when I tried to create measurement based on that IF function I can't get the total correct number of warning.

 

Here is the measurement I'm already done with:

*Metrics 1 are (Total of Fatal Incident + Non Fatal Incident) / Total Complete Order

First I create IF :

Category = 

IF(
AND(
'Query1'[Metrics 1] > 'Parameter : Metrics 1'[Parameter Value],
sum('Query1'[Non Fatal Incident]) > 'Non Fatal'[Non Fatal Value] ||
sum('Query1'[Fatal Incident]) > 'Fatal'[Fatal Value]
), "Warning","Non") 

 

By using this i can create summarize which ID that are warning and non-warning so next step i want to count how many distinc ID that are included in warning, so i use this measurement :

CALCULATE(
DISTINCTCOUNT('Query1'[ID]),
FILTER('Query1','Query1'[Category] ="Warning"))

 

However its turn out that there is a lot of ID that category as Warning are not counted by this measurement, any idea how to do it ? If i use column calculation i can get correct number but its turn out not dynamic and can't have date filter.

 

So I tried to use another way by using var but as far I see I can't create dynamic column measurement if I just want to filter it by 2 months or 3 months. Basically, the final result I want to see is how many distinct ID that is considered as warnings but should be able to dynamic filter by date because if I want it to be dynamic I need to use measurement, but if I do so it's not giving me a correct number, but if I used column its can't be dynamic because its counts all row 

DateIDNon Fatal IncidentFatal IncidentComplete Order
2023-01-01A-1012000
2023-01-02A-1101000
2023-01-03A-100500
2023-01-04A-100322
2023-01-05A-110644
2023-01-06A-110600
2023-01-07A-110233
2023-01-08A-120500
2023-01-09A-201600
2023-01-10A-201233
2023-01-11A-200421
2023-01-12A-200563
2023-01-13A-202654
2023-01-14A-213634
2023-01-15A-210235
2023-01-16A-210754
2023-01-17A-210345
1 REPLY 1
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Count =
COUNTROWS ( FILTER ( VALUES ( 'Query1'[ID] ), [Category] = "Warning" ) )

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.