Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Substract same figures from each category

Hello,

 

If possible maybe someone can support with a solution, I will try to describe my situation:

I have a growing database, each month a new version is uploaded:

 

CustomerPlanned Vol Actual VolumesSource
Daimler10050Jan-20
VW5020Jan-20
Daimler9040Feb-20
VW6020Feb-20
Daimler10040Mar-20
VW6030Mar-20

 

I would like to calculate for each of my sources ( file from Jan , file from Feb..) the difference between the planned volumes and the latest actual volumes. I make a measure to get the latest actual volumes (not sure if this is the way to go)

 

Latest actuals = var max_date = LASTDATE('Overview'[Source])
return CALCULATE(SUM('Overview'[Actual volumes]), FILTER('Overview','Overview'[Source] = max_date))

 

In the example the Daimler 40 / VW 30

Now I want to take the latest volumes and substract them from each monthl version from my database:

 

Source  Planned Vol Lates Actual VolumesDifference
JanDaimler1004060
 VW503020
FebDaimler904050
 VW603030
MarDaimler1004060
 VW603030

 

The difference should be the result. 

 

1 I don'y have any ideea how to achieve that

2 If I try a quick measure to substract the result is only substracting the figures from the March version.

 

Open to any ideas that might help.

Thank you

  • Anonymous ,

     

    Create two measures using dax as below:

    Latest actuals = 
    VAR max_date =
        CALCULATE(MAX( 'Overview'[Source] ), ALL(Overview))
    RETURN
        CALCULATE (
            MAX( 'Overview'[Actual volumes] ),
            FILTER ( ALLEXCEPT('Overview', Overview[Customer]), 'Overview'[Source] = max_date )
        )
    
    Result = 
    MAX(Overview[Planned Vol ]) - [Latest actuals]

    The result is like below:
     

     

    You can also refer to the attached pbix file.

     

    Community Support Team _ Jimmy Tao

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    It looks like you've already solved the hard part.  Why doesn't this work with the two measures you already have?

     

    Difference = [Planned Volume] - [Latest Actual Vol]

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello,

       

      I tried that and  it's only substracting the figures from the March version.

      In my measure it identifies the lates actual figures Daimler 40/ VW 30 , plese find example with my current status

       

      I want to subtract the March values from each source category.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello

      I tried and it's just subtracting the figures from the March version.

      To my extent I identify the actual figures for Daimler 40 / VW 30 delays, plese find example with my current status

      pb.jpg

      I want to subtract the March values from each source category.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello

      I tried and it's just subtracting the figures from the March version.

      To my extent I identify the actual figures for Daimler 40 / VW 30 delays, plese find example with my current status

      pb.jpg

      I want to subtract the March values from each source category.

  • v-yuta-msft's avatar
    v-yuta-msft
    Community Support

    Anonymous ,

     

    Create two measures using dax as below:

    Latest actuals = 
    VAR max_date =
        CALCULATE(MAX( 'Overview'[Source] ), ALL(Overview))
    RETURN
        CALCULATE (
            MAX( 'Overview'[Actual volumes] ),
            FILTER ( ALLEXCEPT('Overview', Overview[Customer]), 'Overview'[Source] = max_date )
        )
    
    Result = 
    MAX(Overview[Planned Vol ]) - [Latest actuals]

    The result is like below:
     

     

    You can also refer to the attached pbix file.

     

    Community Support Team _ Jimmy Tao

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.