Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi,
I am currently trying to create a visual but struggling with some time intelligence calculations. My data has the following structure:
BillID | Legislation Status | Year |
166 | Proposed | 2009 |
166 | Tabled | 2009 |
166 | Passed | 2011 |
166 | Implemented | 2012 |
193 | Proposed | 2011 |
193 | Tabled | 2011 |
193 | Passed | 2011 |
193 | Implemented | 2014 |
However, in order to make a visual I need to "fill in" the values where there are missing years for each BillID:
BillID | Legislation Status | Year |
166 | Proposed | 2009 |
166 | Tabled | 2009 |
166 | Tabled | 2010 |
166 | Passed | 2011 |
166 | Implemented | 2012 |
193 | Proposed | 2011 |
193 | Tabled | 2011 |
193 | Passed | 2011 |
193 | Passed | 2012 |
193 | Passed | 2013 |
193 | Implemented | 2014 |
Does anyone know some smart DAX that could solve this problem? For reference, this is (roughly) the visual I am trying to create:
Any help appreciated, thanks!
Solved! Go to Solution.
@Anonymous Ok, I have another solution for you:
Respectfully,
Zoe Douglas (DataZoe)
Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/
Hi @Anonymous ,
DataZoe has provided a clear method but you need a calendar table. Or you can create a year table as mentioned by him above. Then use the following measure based on your sample data:
Measure = var a = MAX('All Years'[Value]) return COALESCE(MAX('Table'[Legislation Status]),CALCULATE(MAX('Table'[Legislation Status]),ALLEXCEPT('Table','Table'[BillID]),'Table'[Year] = a-1),CALCULATE(MAX('Table'[Legislation Status]),ALLEXCEPT('Table','Table'[BillID]),'Table'[Year] = a-2))
For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EZMKiHLutDZJo0JaoX7hR7QBON50OxZ57PjBM6gbiiqw8A?e=no0CV8
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hi Everyone,
Apologies for not replying sooner but I decided to instead create a Year & BillID scaffold the data warehouse before importing into Power BI.
This means I dont need to create DAX with a fixed number of dates and can instead work dynamically.
Thanks for the suggestions.
@Anonymous You could create a calculated table with all the years you need, then create a relationship to the table.
Modeling --> New Table
Once you have that, change out the year on the visual to the new table's year. Then right-click on the year in the field list, and choose "Show items with no data"
Respectfully,
Zoe Douglas (DataZoe)
Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/
Hi @DataZoe,
Thanks for the response. Unfortunatley that hasn't solved the issue as I am looking to actually "fill in" values for the cells, where if the value for the next year is blank, I fill in the value for the previous year.
Sorry for the crude picture editing but it would be from this:
to this:
Hi @Anonymous ,
DataZoe has provided a clear method but you need a calendar table. Or you can create a year table as mentioned by him above. Then use the following measure based on your sample data:
Measure = var a = MAX('All Years'[Value]) return COALESCE(MAX('Table'[Legislation Status]),CALCULATE(MAX('Table'[Legislation Status]),ALLEXCEPT('Table','Table'[BillID]),'Table'[Year] = a-1),CALCULATE(MAX('Table'[Legislation Status]),ALLEXCEPT('Table','Table'[BillID]),'Table'[Year] = a-2))
For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EZMKiHLutDZJo0JaoX7hR7QBON50OxZ57PjBM6gbiiqw8A?e=no0CV8
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hi Everyone,
Apologies for not replying sooner but I decided to instead create a Year & BillID scaffold the data warehouse before importing into Power BI.
This means I dont need to create DAX with a fixed number of dates and can instead work dynamically.
Thanks for the suggestions.
@Anonymous Ok, I have another solution for you:
Respectfully,
Zoe Douglas (DataZoe)
Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
89 | |
82 | |
53 | |
40 | |
35 |