Forum Discussion
DateSpan
- Anonymous1 year ago
Hi nchamilton2 ,
You're correct that directly joining the DateSpan table to the FactTable introduces a many-to-many relationship, which Power BI doesn’t handle as cleanly as other analytics tools. To support your scenario generating all dates between each phase’s estimated start and end, while avoiding many-to-many joins the recommended approach is to reshape the model slightly by introducing Phases as a bridge table.
First create a dynamic DateSpan table in Power Query that expands each phase into one row per date using this code:
let Source = Phases, ChangedTypes = Table.TransformColumns(Source, { {"EstStartDate", each Date.FromText(_, "en-US"), type date}, {"EstEndDate", each Date.FromText(_, "en-US"), type date} }), AddDateList = Table.AddColumn(ChangedTypes, "Date", each List.Dates([EstStartDate], Duration.Days([EstEndDate] - [EstStartDate]) + 1, #duration(1,0,0,0))), ExpandedDates = Table.ExpandListColumn(AddDateList, "Date"), SelectedColumns = Table.SelectColumns(ExpandedDates, {"PhaseId", "Date", "PhaseName"}) in SelectedColumnsAdjust the relationships in the model:
- DynamicDateSpan[PhaseId] → Phases[PhaseId] (One-to-many)
- FactTable[PhaseId] → Phases[PhaseId] (Many-to-one)
- FactTable[ProjectID] → Projects[ProjectID] (Many-to-one)
Use Phases as the central bridge. This lets both the fact table and the generated date list connect indirectly, avoiding many-to-many conflicts.
To show ProjectTitle, you can either create a measure like:
ProjectTitle := CALCULATE ( SELECTEDVALUE ( Projects[ProjectTitle] ), TREATAS ( VALUES ( DynamicDateSpan[PhaseId] ), FactTable[PhaseId] ), FactTable )Or build a calculated table if you need a flattened structure.
This setup should meet your needs: dynamically showing each phase across all active dates, with project info, while maintaining a clean and performant model.
hope this helps, please feel free to reach out for further issue.
Thank you.
Hi nchamilton2 ,
Thank you for reaching out to the Microsoft fabric community forum. Thank you FBergamaschi and amitchandak for your inputs on this issue.
After thoroughly reviewing the details you provided, I was able to reproduce the scenario, and it worked on my end. The model should have One -Many relation between Fact Table and DateSpan between Date and PhaseStartDate for it to show the table with Date, Phase Name and Project Title.
Please refer to the following images for your understanding:
output:
I am also including .pbix file for your better understanding, please have a look into it:
Hope this helps you resolve the issue. Please reach out for further assistance.
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
- nchamilton21 year agoFrequent Visitor
Thanks for the reply. I'm looking for all dates between the EstPhaseStart and EstPhase End. So if phase start was 1/1/2025 and PhaseEnd was 1/15/2025, I would expect to see
Date Phase
1/1/2025 Planning1/2/2025 Planning
1/3/2025 Planningetc..
It's a slowly changing dimension, I just can't figure out how to incorporate it in Power BI. Other analytics tools, no probablem, but because of the many to many in power bi, it's difficult.