Forum Discussion
Identifying State history Count based on date slicer
- 5 months ago
HI ManuBK,
I have recreated your requirement in Power BI using sample data and attached a sample PBIX file for your reference. You may also find the following Microsoft documentation helpful, as it aligns with this approach.
Slowly changing dimension type 2 - Microsoft Fabric | Microsoft Learn
Understand star schema and the importance for Power BI - Power BI | Microsoft Learn
Thank you.
- 5 months ago
HI ManuBK,
Checking in to see if your issue has been resolved. let us know if you still need any assistance.
Thank you.
Hello,
I guess that the issue here is you’re treating states as events, while your logic really needs intervals, each state is valid from one date until the next change so instead of counting rows, you should build a “valid from / valid to” range per row, basically Start = New State Date, End = next New State Date (per ID), then your slicer should check if the selected period overlaps that interval in DAX terms, something like checking if Start <= slicer max date and End >= slicer min date, that way you count the state if it was active at any point in the selected range if you don’t do this, Power BI just counts transitions, not the actual state during the period, which is why your results feel off I’d try first creating a calculated column for the “next date” per ID (using LEAD logic or EARLIER pattern), then build the measure on top of that, much easier to control
Best regards,
Daniele