Forum Discussion

campelliann's avatar
campelliann
Icon for Post Patron rankPost Patron
4 years ago
Solved

All not removing filter context? Help

Hi friends, The more I think I know about dax, the more I realize this is hell on earth :). Help me understand this please. So I used the Dax Below to get the distinct number of months with rec...
  • ValtteriN's avatar
    4 years ago

    Hi,

    The problem is likely caused by this part of your DAX: 

    && 'Relatório'[Empresa] IN VALUES ( 'Relatório'[Empresa] )

    Now the table expression VALUES ( 'Relatório'[Empresa] ) is affected by filters -> if your filters cause this table to be blank it will in turn cause your calculation to fail.

    Example of similar DAX:

    Value-2 = CALCULATE(SUM('Dateadd-2'[Value]),filter(ALL('Dateadd-2'),'Dateadd-2'[Date] in VALUES('Dateadd-2'[Date])))
     

     

    By slicing the date VALUES('Dateadd-2'[Date]) will return a blank table and thiss will cause everything else to be blank:

    If we use ALL instead of VALUES the problem is gone:

    Value-2 =
    CALCULATE(SUM('Dateadd-2'[Value]),filter(ALL('Dateadd-2'),'Dateadd-2'[Date] in ALL('Dateadd-2'[Date]))
    )

     

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/