Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I want to display a bar chart for revenue so when the user select June, 2021 the chart would only show six months. If they choose December, 2021, then all twelve months are shown. I have filters for both month and year. Any help would be greatly appreciated.
Solved! Go to Solution.
@ShrimpSurf I'm fairly certain that you are going to want a disconnected date table for your slicer. Then you can compare the value selected (MAX or SELECTEDVALUE) with the MAX of the actual date table in the axis of your chart visual and determine whether to return a value in your measure or BLANK().
Hi,
See if my solution here helps - Flex a Pivot Table to show data for x months ended a certain user defined month.
@ShrimpSurf This is not exactly what you're looking for, but may give you some ideas and inspiration: https://excelwithallison.blogspot.com/2021/09/power-bi-forecasting-with-irregular.html
If you share sample data (upload to OneDrive and share link) we can provide more specific measures and help for you, but you'll need to either generate a parameter table OR somehow build into the measure a condition that tells Power BI whether to display 6 months or 12 months, and accounts for all years in your data model.
Parameter table would be best I think, so basically as @Greg_Deckler said, a disconnected table with no relationships to your DimDate or data model that has:
Date | Number Months to Display
June 30, 2021 | 6
December 31, 2021 | 12
June 30, 2022 | 6
....
Then create a DAX measure that uses the parameter table to manipulate the measure:
Filtered Measure =
VAR _startDate = SELECTEDVALUE (Parameter[Date] )
VAR _duration = SELECTEDVALUE Parameter[Number Months to Display] )
RETURN
CALCULATE ( [Measure] , DATESINPERIOD( DimDate[Date], _startDate, -1* _duration, Month)
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@ShrimpSurf I'm fairly certain that you are going to want a disconnected date table for your slicer. Then you can compare the value selected (MAX or SELECTEDVALUE) with the MAX of the actual date table in the axis of your chart visual and determine whether to return a value in your measure or BLANK().
User | Count |
---|---|
93 | |
84 | |
78 | |
75 | |
66 |
User | Count |
---|---|
115 | |
105 | |
93 | |
65 | |
60 |