Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Amir851
Helper I
Helper I

Calculate Row Difference between two consecutive rows based on two consecutive rows & other columns

Dear All,

 

I am trying to calculate row diff between two consecutive rows of Running Total % (which is Measure) based on two consecutive Rank All Machine (which is also Measure). Rank all Machine is being calculated based on the Sum of duration.

 

There are also four slicers named Machine, Machine Type, year & week available in the report and Component, Sum of Duration, Machine, Machine Type, Year & week are part of Table named Downtime.

 

Row Diff of Running Total % should be calculated based on two consecutive Ranks(Rank 3 row - Rank 2 row & Rank 6 row - Rank 5 row)

 

I have tried below dax but it is not working and tr returns an empty value.

 

Row diff =
VAR NEXT =[Rank All Machine] +1
return
CALCULATE([Running Total %],FILTER(Downtime,Downtime[Running Total %]=NEXT))

 

@Phil_Seamark @v-shex-msft  Can you please help me with this request.

 

Component (Table column)Sum of Duration (Table Column)Running Total %(Measure)Rank All Machine(Measure)Row Diff(Need New Measures)   
Component 94.8540,1010,00   
component 32.1057,40217,30 slicer 1-Machine
component 21.3768,70311,30   
Component 41.3579,90411,20 slicer 2- Machine type
component 60.7085,6055,70   
component 50.6390,8065,20 slicer 3- Year
Component 80.4994,9074,10   
component 120.4598,7083,80 slicer 4- week
Component 70.1299,7091,00   
Component 100.0299,80100,10   
3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @Amir851 ,

Maybe you can do like this:

rows_diff = 
CALCULATE(
    SUM([R_total]),
    FILTER(
        'Sales (3)',
        [Run_all] = EARLIER([Run_all]) + 1
    )
)

c12.PNG

But, pay attention, my [R_total], [Run_all] , [rows_diff] are all calculated column.

I tried to do it by measures, but don't get it.

Hope the result is what you want.

 

Best regards,
Lionel Chen

 

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

 

Dear @v-lionel-msft ,

 

Thank you for your response.

 

Actually , I know how to implement the above scenario with calculated columns. But in my current requirement all the columns except description are measures. I want to implement the above scenario using measures only.

 

Can you please let me know whether is there any possibilities to implement the above scenario by considering all those columns as measures.

 

Thanks

Amir 

Hi @Amir851 ,

I did initially plan to use measure to do this, but I found it impossible.
Measure and column are not  arbitrary. They have different return values, so they use different functions.
Here's an article about measure and column:
https://docs.microsoft.com/en-us/dax/dax-overview 

Best regargs,
Lionel Chen

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.