We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Dear all,
I have a question and I request some support. (I am trying to solve this in Power BI but maybe its a real back-end issue)
In Power BI we consume a starschema where different products (Dim_Product) had different purchases in Fact_ProductTransactions.
The issue I have, some products belong to different categories and I have to calculate the leadtime of a product in each category.
| Order | ID | Name | Group-Bike | Group-Car | Group-Truck | StartDate | EndDate |
| 1 | A1 | Product A1 | Bike | Truck | 01/01/2021 | 01/04/2026 | |
| 2 | A2 | Product A2 | Bike | Truck | 01/01/2021 | 01/04/2026 | |
| 3 | A2.5 | Product A3 | Bike | Truck | 01/01/2021 | 01/04/2026 | |
| 4 | A3 | Product A4 | Bike | Truck | 03/01/2021 | 01/04/2026 | |
| 5 | A4 | Product A5 | Bike | 03/01/2021 | 01/04/2026 | ||
| 6 | A5 | Product A6 | Bike | Truck | 01/01/2021 | 01/04/2026 | |
| 7 | A6 | Product A7 | Bike | Truck | 01/01/2021 | 01/04/2026 | |
| 9 | A7 | Product A8 | Bike | Truck | 01/01/2021 | 01/04/2026 | |
| 10 | A8 | Product A9 | Bike | 01/01/2021 | 02/04/2026 | ||
| 11 | A9 | Product A10 | Bike | Truck | 02/01/2021 | 01/04/2026 | |
| 13 | A58 | Product A11 | Bike | Truck | 04/11/2024 | 01/04/2026 | |
| 14 | A59 | Product A12 | Bike | Truck | 04/11/2024 | 27/03/2026 | |
| 15 | A60 | Product A13 | Bike | Truck | 14/11/2024 | 31/03/2026 | |
| 16 | A61 | Product A14 | Bike | Truck | 14/11/2024 | 01/04/2026 | |
| 17 | A62 | Product A15 | Bike | Truck | 12/12/2024 | 01/04/2026 | |
| 18 | A11 | Product A16 | Bike | Car | 04/01/2021 | 31/03/2026 | |
| 19 | A12 | Product A17 | Bike | Car | 04/01/2021 | 31/03/2026 | |
| 20 | A13 | Product A18 | Bike | Car | 04/01/2021 | 31/03/2026 | |
| 21 | A53 | Product A19 | Bike | Truck | 12/01/2021 | 31/03/2026 | |
| 22 | A52 | Product A20 | Bike | Truck | 04/01/2021 | 31/03/2026 | |
| 23 | A55 | Product A21 | Truck | 31/03/2022 | 31/03/2026 | ||
| 24 | A56 | Product A22 | Bike | Car | 30/06/2022 | 27/03/2026 | |
| 25 | A14 | Product A23 | Bike | Car | 03/01/2021 | 31/03/2026 | |
| 30 | A19 | Product A24 | Bike | Car | 04/01/2021 | 31/03/2026 | |
| 31 | A20 | Product A25 | Bike | Truck | 04/01/2021 | 01/04/2026 | |
| 32 | A21 | Product A26 | Bike | Truck | 04/01/2021 | 01/04/2026 | |
| 33 | A31 | Product A27 | Bike | Truck | 04/01/2021 | 02/04/2026 | |
| 34 | A22 | Product A28 | Bike | Car | 03/01/2021 | 31/03/2026 | |
| 35 | A23 | Product A29 | Truck | 04/01/2021 | 01/04/2026 | ||
| 37 | A25 | Product A30 | Car | 04/01/2021 | 31/03/2026 | ||
| 38 | A26 | Product A31 | Truck | 03/01/2021 | 01/04/2026 | ||
| 39 | A27 | Product A32 | Car | 04/01/2021 | 31/03/2026 | ||
| 41 | A49 | Product A33 | Truck | 22/04/2021 | 31/03/2026 | ||
| 42 | A29 | Product A34 | Truck | 04/01/2021 | 31/03/2026 | ||
| 43 | A30 | Product A35 | Car | 04/01/2021 | 31/03/2026 | ||
| 44 | A32 | Product A36 | Truck | 04/01/2021 | 01/04/2026 |
You can see that sometimes a category (Bike-Car-Truck) is blank if we would like to:
1. Use all three columns as slicer (This I can solve using Field Parameter option)
2. Calculate leadtime (DateDiff between start and end date in days) based on the following conditions:
a. Blank should be ignored
b. Overalpping start and end date need to be ignored (We dont want double leadtime, if they run at the same time then only take 1 or deduct the overlapping leadtime)
c. Gaps between products (If a product starts in a year after the previous product ends) need to be ignored or deducted from total leadtime
So far what I though about. Maybe some more scenario's will promt up in the next days as I am analyzing the data and all modelling options.
Hi @Hichamas4 , Thank you for reaching out to the Microsoft Community Forum.
We find the answer shared by @Zanqueta is appropriate. Can you please confirm if the solution worked for you. It will help others with similar issues find the answer easily.
Thank you @Zanqueta for your valuable response.
Hi @Hichamas4
Using the same sample data provided, please show your expected result and the explanation behind.
Note: I had to emphasize using the same sample data provided as there were users who provided the expected result but used a different data.
Hi @Hichamas4
Categories left blank must be ignored.
Overlapping date intervals must not be counted twice.
Gaps (periods where no interval exists) must not contribute to the total lead time.
Duplicate the raw product table.
Unpivot the three category columns.
Remove rows where the category value is blank.
Produce a table containing only ProductID and Category.
Dim_Date
Fact_ProductTransactions
Dim_Product
Bridge_ProductCategory
Dim_Category
Calculate lead time by counting distinct active days.
Use simple DAX to sum the lengths of consolidated intervals.
If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 38 | |
| 33 | |
| 17 | |
| 17 |
| User | Count |
|---|---|
| 67 | |
| 63 | |
| 38 | |
| 34 | |
| 22 |