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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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

Anonymous
Not applicable

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.