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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Calculate datediff of many status in a events table in M code

Hi all

 

I got this thread (https://community.powerbi.com/t5/Desktop/Calculate-datediff-of-many-status-in-a-events-table/m-p/741...) were I got a solution with a DAX measure. It worked very well and I could use it for all the commands needed but as the DB got bigger it is very slow and I got limitations to make calculations in a row level. I think this would be better to be done in query editor with M code. Please could somebody givi me a hand to get a solution this way?

 

Cheers.

Pepe

 

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

According to your oringin DAX, I get the result with m query.

I uploaded my test file, you can download and refer to it.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

Hi @v-eachen-msft 

 

Very much appreciated your effort. This gives a solution to the sample provided, but the way you get the dates with the megerType won't work in the whole table.

There are several different types of commands and not always the command to star the procces is the number before the command to end the process.

We've got a porces that stars with commands 27 (deploy fro postpro) and end with command 4 (import mastered audio).

Apart from the commands, the description field identifies different process of the same type. Meaning that the Commands 9 should get the duration from commands 8 that matches the description.

 

Could the "merge type" step be done with a conditional to match pairs of commnads (not consecutive) and that matches also a 3rd value like description?

somethingt like this:

= Table.AddColumn(#"Changed Type", "mergeType", each 
              if [CommandType] = 9 then 8
             else if [CommandType]=6 then 5
             else null)

but it needs to macht the description too.

 

Cheers

Pepe

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors