Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

CALCULATE + FILTER +ALL

Hello guys,

 

I have following table

 

month
1
2
3
4
5
6

 

And I need to create measure  that will return count of month and not be affected by selection/filter of months, I create this DAX formula, but for unknown reason it is not working, any reason why? and what should be correct syntax ?

 

measure= CALCULATE(DISTINCTCOUNT(Table[month]),ALL(Table,Table[month])))

 

 

  • VahidDM's avatar
    VahidDM
    4 years ago

    Anonymous 

     

    You set a filter on Date column so use one of these:

     

    count_m_fix = CALCULATE(DISTINCTCOUNT(Sheet1[y_m]),ALL(Sheet1))
     
    or 
     
    count_m_fix = CALCULATE(DISTINCTCOUNT(Sheet1[y_m]),ALL(Sheet1[Date]))
     
     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/


     

     

10 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    I also tried

    measure

    = CALCULATE(DISTINCTCOUNT(Table[Month]),ALL(Table[Month]))
     
    but when I changed filter on the page this measure is updated as well, instead of to be fixed
  • HI Anonymous 

     

    Try this:

     

    measure= CALCULATE(DISTINCTCOUNT(Table[month]),ALL(Table[month]))

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hell Vahid  this is what I mentioned in 2nd post (I have typo here with ")") but it doesn t work

       

      • VahidDM's avatar
        VahidDM
        Super User

        Anonymous 

         

        Can you share you PBIX file?

        or try this if you set a filter on month and you want to ignore that:

         

        measure =
        CALCULATE ( DISTINCTCOUNT ( Table[Month] ), REMOVEFILTERS ( Table[Month] ) )

         

          

        If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
        Appreciate your Kudos!!
        LinkedIn: 
        www.linkedin.com/in/vahid-dm/