Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello everybody!
I have the following scenario: I have a table with order IDs. This table also contains the creation date of the orders and the current check date (every seven days). There are also two columns for orders in process and finished orders.
That means on every check date (every seven days) a new row is created for each order, where the current status of the order (In process or finished) is newly evaluated and marked in the corresponding column.
This is the table with example data:
OrderId | CreatedAt | CheckDate | InProgress | Finished |
1 | 11.01.2021 | 25.01.2021 | X | |
2 | 18.01.2021 | 25.01.2021 | ||
3 | 18.01.2021 | 25.01.2021 | ||
4 | 25.01.2021 | 25.01.2021 | ||
1 | 11.01.2021 | 01.02.2021 | X | |
2 | 18.01.2021 | 01.02.2021 | X | |
3 | 18.01.2021 | 01.02.2021 | ||
4 | 25.01.2021 | 01.02.2021 | X | |
5 | 01.02.2021 | 01.02.2021 | X | |
6 | 01.02.2021 | 01.02.2021 | ||
1 | 11.01.2021 | 08.02.2021 | X | |
2 | 18.01.2021 | 08.02.2021 | X | |
3 | 18.01.2021 | 08.02.2021 | ||
4 | 25.01.2021 | 08.02.2021 | X | |
5 | 01.02.2021 | 08.02.2021 | X | |
6 | 01.02.2021 | 08.02.2021 | X | |
7 | 08.02.2021 | 08.02.2021 |
Now I want to create a measure that always calculates the average processing time for a selected check date.
This is my current calculation for it:
The problem is that my Measure does not use the check date when an order was first given the status "In Progress" or "Finished". Instead, it always uses the check date selected by the filter.
For example, in the screenshot the measure shows a result of 15.40 days.
But the correct solution should be 8.4 days as is shown here, which I need for my report:
Correct Average Processing Time for CheckDate=08.02.2021: | |||
Id | CreatedAt | Processed first at CheckDate | Days |
1 | 11.01.2021 | 25.01.2021 | 14 |
2 | 18.01.2021 | 01.02.2021 | 14 |
4 | 25.01.2021 | 01.02.2021 | 7 |
5 | 01.02.2021 | 01.02.2021 | 0 |
6 | 01.02.2021 | 08.02.2021 | 7 |
Calculation (14 + 14 + 7 + 0 + 7) / 5 = 8,4 |
And this is the current wrong calculation of my measure:
Current wrong calculation of Average Processing Time for CheckDate=08.02.2021: | |||
Id | CreatedAt | last CheckDate | Days |
1 | 11.01.2021 | 08.02.2021 | 28 |
2 | 18.01.2021 | 08.02.2021 | 21 |
4 | 25.01.2021 | 08.02.2021 | 14 |
5 | 01.02.2021 | 08.02.2021 | 7 |
6 | 01.02.2021 | 08.02.2021 | 7 |
Calculation (28 + 21 + 14 + 7 + 7) / 5 = 15,4 |
Does anybody have an idea how to rewrite this measure to get the correct average processing time, even when I filter my data with the data slicers as shown in the screenshot? Hope you guys can help me out!
Thank you and kind regards!
JMPowerBI
Solved! Go to Solution.
This measure returns the 8.4 you're expecting for 8 Feb selection.
It iterates the unique combinations of Order ID and CreatedAt, calculates the first date when In Progress or Finished (called _FirstProcessed) & the number of days between that and CreatedAt (_CheckDays) for each row and finally gives the average.
This measure returns the 8.4 you're expecting for 8 Feb selection.
It iterates the unique combinations of Order ID and CreatedAt, calculates the first date when In Progress or Finished (called _FirstProcessed) & the number of days between that and CreatedAt (_CheckDays) for each row and finally gives the average.
Hello @PaulOlding!
Many, many thanks for your wonderful and super fast solution! It works perfectly, I am so happy!
Thank you very much and many greetings!
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
26 | |
20 | |
19 | |
14 | |
13 |
User | Count |
---|---|
43 | |
36 | |
24 | |
24 | |
22 |