Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Calculate difference of % between two rows

Hello Community,

 

I tried to find through the forums a solution to my problem. So the "recovery Service Level" is a created measure that calculate the Lines Shipped cumulative divided by the Sum of the Lines Shipped (in total i have 26'303 Lines Shipped). The last column is a simple way to see how much % was added in comparison with the one below. But i am struggling to find a robust solution. Is there a way to create a measure (and not a column) to calculate it? How to create a measure that calculates the difference of % between two rows dynamically?

 

 

 

Days LateLines ShippedRecovery Service Level% added
                                          -    2359389.70% 
                                     1.00  41291.26%1.57%
                                     2.00  17591.93%0.67%
                                     3.00  17692.60%0.67%
                                     4.00  15993.20%0.60%

 

 

Best Regards,

 

Marc Parker

4 Replies

  • Anonymous , Difference between two rows can not be done. So we need to create a formula that takes care of that. Like row value is day or month, we create prior day/month and take diff

  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous 

    Create measures

    Recovery Service Level% =
    VAR total = 26303
    RETURN
        CALCULATE (
            SUM ( 'Table'[Lines Shipped] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Days Late]
                    <= MAX ( 'Table'[Days Late] )
            )
        ) / total
    
    added =
    VAR total = 26303
    RETURN
        IF (
            MAX ( [Days Late] ) <> 0,
            CALCULATE (
                SUM ( 'Table'[Lines Shipped] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[Days Late]
                        = MAX ( 'Table'[Days Late] )
                )
            ) / total
        )
    
    

     

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much Maggie, it seems to work indeed. What if i wanted a dynamic calculation that would change the amount of lines Shipped ? Dynamic with the slicer i want to apply?

       

      Best regards,

       

      Marc 

  • Anonymous's avatar
    Anonymous
    Not applicable

     

    Hi Anonymous ,

     

    If you are looking for calculating the Service Line Added, you can simply use the below measure.

     

    Service Line added = DIVIDE ( SUM ( 'Table' [Lines Shipped])) , 26303)

     

    You do not need to find the row difference in this case.

     

    Mathematical function, you are Calculating [(23593+412)/26303] - (23593/26303) . This translates to 412/26303.

     

    Hope I was able to explain this.

     

    Attaching an excel screenshot for the same.

     

     

    Regards,

    Harsh Nathani

     

    Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!