Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Use CALCULATE and VALUES function to omit column values.

Hi.

 

I just wanted to know whether using CALCULATE and DAX, can we create a measure such that a specific column value is ignored.

 

I have a table called 'Environment Name' and "Quantitiy'.

Environment Table contains names as 'Air','Water' and 'Land'.

 I want to create 3 measures each for Air, Water and Land such that the first measure(Air) can have just the values from Water and Land and vice versa.

 

I have tried doing the same using two DAX queries, but I am not getting a s atisfactory solution.

2 ways which I used to write the query is given below;

 

1)No Air = CALCULATE(SUM(Purchase[Quantity]),VALUES(Environment[EnvironmentName])<>"Air")

 
2)No Air = CALCULATE(SUM(Purchase[Quantity]),Environment[EnvironmentName]<>"Air")
 
If anyone knows how to solve this, then please tell.
 
Regards,
Sanket Bhagwat

 

  • Anonymous , Try like

    CALCULATE(SUM(Purchase[Quantity]),filter(Environment, Environment[EnvironmentName]<>"Air"))

     

    assuming slicer is no filtering the value

     

    else

     

    CALCULATE(SUM(Purchase[Quantity]),filter(all(Environment), Environment[EnvironmentName]<>"Air"))

     

     

    or

     

    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

    if needed check

    Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

2 Replies

  • Anonymous , Try like

    CALCULATE(SUM(Purchase[Quantity]),filter(Environment, Environment[EnvironmentName]<>"Air"))

     

    assuming slicer is no filtering the value

     

    else

     

    CALCULATE(SUM(Purchase[Quantity]),filter(all(Environment), Environment[EnvironmentName]<>"Air"))

     

     

    or

     

    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

    if needed check

    Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Amit.

      The query

      'CALCULATE(SUM(Purchase[Quantity]),filter(Environment, Environment[EnvironmentName]<>"Air"))' worked perfectly fine.

      Thanks for the help!

       

       

      Regards,

      Sanket Bhagwat