Forum Discussion
Need help for generating raw wise difference from column using DAX or power query
- 1 year ago
Hi again
Please try ask the right question first time, because it is a bit annoying having to answer twice πππ
Click here to download a solution ftom one drive
This method will work for 25 machines or more
Please will you now click [thumbs up] and [accept solutoon button]. Thank you !
How it works ...
For the date correctly
Select the Date and Shift columns, then Transform> Unpiciot>Unpivot other columns
Sort by Machine, Date and Shift
Add an index column from 0 incrementing by 1
Get the machine and reading for the previous row
Change reading to numeric data types
and add a conditional columnRenove the unneeded columns and change the usage ro a numeric data type
Draw your graph
Hey Nicks612 ,
To calculate the difference in readings (Machine A and Machine B) shift-wise in Power BI using DAX and Power Query, here's a detailed breakdown for both approaches.
Power Query Steps
You can sort the data and use the Index method to calculate the difference:
Sort the table:
Sort by Date (ascending), then Shift (custom order: 1st Shift, 2nd Shift, 3rd Shift).
Add Index Column:
Add an Index column starting from 0.
Duplicate the table:
Right-click the query and Duplicate.
Rename duplicated columns:
Rename Machine A to Prev Machine A, Machine B to Prev Machine B, and Index to Prev Index.
Merge Queries:
Merge the original table with the duplicated one using:
Index = Prev Index + 1 (join on: Index from original and Prev Index from duplicate).
Expand columns:
Expand Prev Machine A and Prev Machine B.
Add Difference columns:
Difference A = [Machine A] - [Prev Machine A] Difference B = [Machine B] - [Prev Machine B]
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) itβs greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam