Forum Discussion

nmaddock's avatar
nmaddock
Icon for Helper I rankHelper I
7 years ago
Solved

DAX calculation in a different context

Hi,

 

Im trying to calculate Kg's per M3 for industry types based on all the jobs we have already done and then use this value in a report in a different context. i'e' in the context of a service agreement. The problem is because the context has changed it doing the calculations against jobs of the particular agreements instead of all the jobs which is what I want.

For eaxmple if i take Cafe as an example, the weight, volume and kg's per m3 is calculations are correct.

 

If I use this in a different report and add on agreements I get the following:

 

What I want to achieve is below, how can I do this?

 

Please find link the sample file, any help is much appreciated.

https://www.dropbox.com/s/tfiu1tnlsessn47/Power%20BI%20Sample.pbix?dl=0

 

Nathan

  • Hello nmaddock 

    You can use ALLSELECTED over your table to achieve your goal.

    KG's Per M3 = 
    IF ( NOT ISBLANK ( [Total Weight] ),
        CALCULATE(
            DIVIDE([Total Weight], 
            DIVIDE([Total Volume],1000))  
            ,ALLSELECTED(Agreement)
        )
    )

6 Replies

  • Hello nmaddock 

    You can use ALLSELECTED over your table to achieve your goal.

    KG's Per M3 = 
    IF ( NOT ISBLANK ( [Total Weight] ),
        CALCULATE(
            DIVIDE([Total Weight], 
            DIVIDE([Total Volume],1000))  
            ,ALLSELECTED(Agreement)
        )
    )

    • nmaddock's avatar
      nmaddock
      Icon for Helper I rankHelper I

      That worked perfect, thank you :-) its easy when you know how 

      • jdbuchanan71's avatar
        jdbuchanan71
        Icon for Super User rankSuper User

        Hello nmaddock 

        Because the [KG's Per M3] measure needs [Total Weight] and [Total Volume] and on those line with blanks there is no weight or volume we get blank.  What would be the basis of the calculation for those lines?  Meaning, what should it be and how did you get to that number?