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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MLinux
Regular Visitor

Calculate countax vs counta

I need your clarification I've table and I need to count all contents include numbers and text on specific column with specific condition

 

When use calculate(countax(Roster[today shift]), Age < 34) it gives me wrong result while calculate(counta(Roster[today shift], Age < 34) give right one what's the difference between them in this case?

 

I think I still don't understand filter concept in dax

1 ACCEPTED SOLUTION
v-yaningy-msft
Community Support
Community Support

Hi, @MLinux 

According to your description, Here is why using calculate(countax(Roster[today shift])), Age < 34) gives different results,

 

Assuming that the calculation context is the same for both measures

1.calculate(counta(Roster[today shift], Age < 34)) counts the number of rows with non-null values in the today shift column where the age column is less than 34 in the current calculation context.

  1. calculate(countax(Roster[today shift])), Age < 34) counts the number of non-blank rows in the Age < 34 column iterated over Roster[today shift] in the current calculation context.

Related Links:

Context in DAX Formulas - Microsoft Support

DAX Power BI: Iterative X-Functions (SUMX, AVERAGEX, COUNTX) | by Andrei Khaidarov, PhD | Power Plat...

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
v-yaningy-msft
Community Support
Community Support

Hi, @MLinux 

According to your description, Here is why using calculate(countax(Roster[today shift])), Age < 34) gives different results,

 

Assuming that the calculation context is the same for both measures

1.calculate(counta(Roster[today shift], Age < 34)) counts the number of rows with non-null values in the today shift column where the age column is less than 34 in the current calculation context.

  1. calculate(countax(Roster[today shift])), Age < 34) counts the number of non-blank rows in the Age < 34 column iterated over Roster[today shift] in the current calculation context.

Related Links:

Context in DAX Formulas - Microsoft Support

DAX Power BI: Iterative X-Functions (SUMX, AVERAGEX, COUNTX) | by Andrei Khaidarov, PhD | Power Plat...

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Thx for your help

what I notice that when use iterative x function within filter function such as calculate it will ignore the filter if it happen in same table so in this case normal function like counta is right choice for my case

This both makes sense and makes my head hurt

I think may because we've misunderstanding for filter and x-function behaviour

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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