Forum Discussion

MLinux's avatar
MLinux
Regular Visitor
2 years ago
Solved

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

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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 Platform | Medium

     

    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

    • Anonymous's avatar
      Anonymous
      Not applicable

      This both makes sense and makes my head hurt

      • MLinux's avatar
        MLinux
        Regular Visitor

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

         

    • MLinux's avatar
      MLinux
      Regular Visitor

      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