Forum Discussion
How to add hours differences from same column
Hi! I'm wondering how I can extract hours differences between PM_OPENED_AT between the one Preventative Maintenance and following each NON-Preventative Maintenence.
I appreciate your help!
Best,
Linsey
3 Replies
- timahenning2Helper II
Do you have a column that relates the rows to the same transaction? You need some start and end data relationship. Once you have that, you can use something like:
This will give you a difference between two fields in Powery Query. Can you provide more context?
Tim
- LK1992Frequent Visitor
I know, but the thing is when I differentiate to date columns in Preventative and Non-Preventative, it does gives like this. So I can't get differences between these two columns since if there is value in NON_PM Date, there is empty value in same row in PM_OPENS column.
- timahenning2Helper II
Looking at your sampledata, it am guessing the 'PM_OPENED_AT' field is your starting datetime field and 'PM_Date' is your finish/end datetime field. It looks like the time span difference betwen the two fields is minutes. That seems like your granularity. If you added a column in the Power Query table with the timespan value, you could derive an aggregate difference value in Power BI using DAX. For example: SUM('MyTable'[Timespan In Minutes']). Using CALCULATE, you could filter the 'Type' field to your desired dimension value.