Forum Discussion

yugofukuda's avatar
yugofukuda
Helper IV
5 years ago
Solved

How to calcuate the difference

HI,

I would like to calculate the difference between two numbers as below but I can´t tell how to do that (if age is like date, I can do that but in this case, I want to use "Age" as below). 
It would be appriciated if you could give me how to do this!

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi yugofukuda ,

     

    Try this measure please.

    Difference = 
    SUM ( 'Table'[Percent] )
        - CALCULATE (
            SUM ( 'Table'[Percent] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Date] ),
                [Age]
                    = MAX ( 'Table'[Age] ) - 1
            )
        )

     

     

    You can check more details from here.

     

     

    Best Regards,

    Stephen Tao

     

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

5 Replies

  • @yugofukuda ,

    You need to have the table for Age. Suppose Age is a column and you can create a table about that and join again


    Current edad: calculate([Measure], filter(All(Age) , Age[Age] á max(Age[Age])))

    Last Age á calculate([Measure], filter(All(Age) , Age[Age] á max(Age[Age])-1))

    diff á [Edad actual] - [Last edad]

    You can do without a separate table, but then you need to handle too many things

    • yugofukuda's avatar
      yugofukuda
      Helper IV

       

      Thank you very much! I created Age table and I tried to create the measures but "Last Age" didn´t work well. How should I do?

    • yugofukuda's avatar
      yugofukuda
      Helper IV

      Thank you for your support but I can't share my file because this information is confidencial.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi yugofukuda ,

     

    Try this measure please.

    Difference = 
    SUM ( 'Table'[Percent] )
        - CALCULATE (
            SUM ( 'Table'[Percent] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Date] ),
                [Age]
                    = MAX ( 'Table'[Age] ) - 1
            )
        )

     

     

    You can check more details from here.

     

     

    Best Regards,

    Stephen Tao

     

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