Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I'm using this visualization and I have down pat showing "current selected" data. What I'm wondering how to do is on the same page - show the current selected time period from the slicer (say in a bar graph) and have a bar right next to it that shows the previous unit of time that is selected. For instance if I have the month of August selected, I would want this bar graph to show August and July next to each other. If I changed the slicer to show year, I would want 2016 and 2015 to show on the graph. Is there a way to write DAX that goes back one time period based on what slice is selected from the slicer?
Hi @ngg4686,
Agree with CahabaData. When creating a measure to show data of previous year/quarter/month, you can use PREVIOUSYEAR function, PREVIOUSQUARTER function and PREVIOUSMONTH function . There is an example about how to show data of current quarter and previous quarter in this article for your reference.
Besides, in your scenario, why not directly select date ranges in Timeline slicer and combine built-in date hierarchy of Power BI Desktop to show data in your graph? An example is shown in the following screenshot.
Thanks,
Lydia Zhang
I believe one cannot put the cart in front of the horse - or in this case the slicer in front of the calculation - - - sorry for bad joke.....
In your data model where you now have value 'X' - you want also a measure/column along side with value 'X-prior year' (or whichever period). So that X and X-prior are side by side values. Then if you filter on X the X-prior value is available to you.
Is there a way that I can set a dynamic date heriarchy? If I have "week" selected, I want a bar graph to show week over week what is going on. If I change it to "Month" I want to see data aggregated by month. Basically in the bar graph "Axis" I would want something that looks at slicer to determine how to set the heirarchy.
When your granular row value is a date - the Power BI features can expand that date into its fields for week, month, quarter values.
You can use those period values for filtering & aggregating
Any value fields of that data model can be aggregated by those periods.
so I believe you can get what you seek if I understand your question......
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |