cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JurreVanGool Frequent Visitor
Frequent Visitor

How to select only show previous X months in visual

Hi,

 

Pretty new to Power BI and ran into the following challenge:

I have a linechart visual which I want to adjust according the user selection in a slicer (months). So if the user selects July I want to only show the values $Actual for the month July and the previous 5 months (June, May, Apr, Mar, Feb). Ofcourse I managed to do this hardcoded $ActualHardcoded, also see table, however the challenge is to get this in a dynamic form.

 

$ActualHardcoded =
CALCULATE(sum('Act/Bud/Est'[Value]);
 FILTER('Act/Bud/Est';'Act/Bud/Est'[Scenario]="actual");
 FILTER('date';'date'[MonthIndex]>493); //493 is monthindex Jan
 FILTER('date';'date'[MonthIndex]<=499)) //499 is monthindex Jul (selection) 

 

Img:

1 is current data (not linked to slicer Month)

2 is preferred end result

 Power BI

Thanks in advance! 

 

(I did notice other people had similar issues in other topic however I did not manage to apply those to my solution 😞 ).

 

Jurre

1 ACCEPTED SOLUTION

Accepted Solutions
v-yulgu-msft Super Contributor
Super Contributor

Re: How to select only show previous X months in visual

Hi @JurreVanGool,

 

Here is a sample which shows how to display previous X days in visual based on slicer selection, the logic is similar to your scenario:

Rolling N Dates based on slicer selection

 

By the way, you'd better set the X-axis type to 'Categorical'.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Highlighted
Super User
Super User

Re: How to select only show previous X months in visual

Hey,

 

to solve this you need an unrelated table, this table then is used for the selection used on the xaxis.

 

Then you have to adjust your measures to map the table on the unrelated table. Here you will find a pbix file Have a look at the page "Date axis unrelated".

 

Hope this helps

 

Regards

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!
v-yulgu-msft Super Contributor
Super Contributor

Re: How to select only show previous X months in visual

Hi @JurreVanGool,

 

Here is a sample which shows how to display previous X days in visual based on slicer selection, the logic is similar to your scenario:

Rolling N Dates based on slicer selection

 

By the way, you'd better set the X-axis type to 'Categorical'.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

calerof Member
Member

Re: How to select only show previous X months in visual

@v-yulgu-msft , 

Access denied to your link.

F

 

Helpful resources

Announcements
Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 151 members 1,712 guests
Please welcome our newest community members: