The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I am trying to show the data for the past three months on the bar charts and I keep failing to do so. It will usually come up with data for all the months. What I expect is that I can show the sales of the latest 3 months when the slicer for month is not filtered, if not the bar chart will show the data of the months selected in the slicer. Is there any DAX or ways that could help me solving this? Appreciate any kind of advice or knowledge related.
Solved! Go to Solution.
Hi @Anonymous ,
According to you description, you want to have month as axis in a chart, as well as month in a slicer. In Power BI it is not possible to separate filter context coming from a chart/visualization from filter context coming from a slicer.
In order to do what you are trying to do, you need to keep a separate month table and use this table for slicer values. Then you can create this measure:
Measure =
IF (
ISFILTERED ( Months[monthNo] );
CALCULATE (
SUM ( 'Table'[Sales] );
FILTER ( 'Table'; 'Table'[monthNo] IN VALUES ( Months[monthNo] ) )
);
CALCULATE (
SUM ( 'Table'[Sales] );
FILTER ( 'Table'; 'Table'[monthNo] >= MONTH ( TODAY () ) - 2 )
)
)
here is a demo
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
How to Get Your Question Answered Quickly
Hi @Anonymous ,
According to you description, you want to have month as axis in a chart, as well as month in a slicer. In Power BI it is not possible to separate filter context coming from a chart/visualization from filter context coming from a slicer.
In order to do what you are trying to do, you need to keep a separate month table and use this table for slicer values. Then you can create this measure:
Measure =
IF (
ISFILTERED ( Months[monthNo] );
CALCULATE (
SUM ( 'Table'[Sales] );
FILTER ( 'Table'; 'Table'[monthNo] IN VALUES ( Months[monthNo] ) )
);
CALCULATE (
SUM ( 'Table'[Sales] );
FILTER ( 'Table'; 'Table'[monthNo] >= MONTH ( TODAY () ) - 2 )
)
)
here is a demo
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
How to Get Your Question Answered Quickly
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
20 | |
18 | |
18 | |
18 | |
14 |
User | Count |
---|---|
40 | |
35 | |
23 | |
20 | |
20 |