cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PBIfanatic
Helper IV
Helper IV

Show dates less than the selected slicer month

Hi,

 

I have a line chart using year and month on the x axis and a measure on the y axis.

Is there a way we can use a slicer and show the data in the chart for months only prior to the selection.

Lets say we select March 20, the chart should show data from March 20 backwards.. even if we have data till July 20.

Is this possible?

 

 

 

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @PBIfanatic 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

e1.png

 

Calendar(a calculated table) :

Calendar = CALENDARAUTO()

 

You may create calculated columns and measures as below.

Calculated column:

Calendar Year-Month = YEAR('Calendar'[Date])*100+MONTH('Calendar'[Date])
Table Year-Month = YEAR('Table'[Date])*100+MONTH('Table'[Date])

 

Measure:

Visual Control = 
IF(
    SELECTEDVALUE('Table'[Table Year-Month])<SELECTEDVALUE('Calendar'[Calendar Year-Month]),
    1,0
)

 

Finally you may put the measure in the visual level filter and use the date column from ‘Calendar’ table to filter the result.

e2.png

 

Best Regards

Allan

 

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

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @PBIfanatic 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

e1.png

 

Calendar(a calculated table) :

Calendar = CALENDARAUTO()

 

You may create calculated columns and measures as below.

Calculated column:

Calendar Year-Month = YEAR('Calendar'[Date])*100+MONTH('Calendar'[Date])
Table Year-Month = YEAR('Table'[Date])*100+MONTH('Table'[Date])

 

Measure:

Visual Control = 
IF(
    SELECTEDVALUE('Table'[Table Year-Month])<SELECTEDVALUE('Calendar'[Calendar Year-Month]),
    1,0
)

 

Finally you may put the measure in the visual level filter and use the date column from ‘Calendar’ table to filter the result.

e2.png

 

Best Regards

Allan

 

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

@v-alq-msft  thats brilliant!!

Exactly what I was after. Thanks so much.

Ashish_Mathur
Super User III
Super User III

Hi,

See if my solution here helps - Flex a Pivot Table to show data for x months ended a certain user defined month.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AllisonKennedy
Super User III
Super User III

@PBIfanatic
You could change the date slicer to a BEFORE option or a RELATIVE slicer: https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range

You could also really complicate things by updating your visuals to use measures that take the selected date in the slicer and return data for all dates prior to that using Time Intelligence DAX, but that would not be my recommended approach.


Has this post solved your problem? Please mark it as a 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. ?


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

pranit828
Super User II
Super User II

Hi @PBIfanatic 

 

A date slicer when used will always show data for the selected date and nothing pre or post the selected date.

 

I would use the input parameter instead in your case. below is the link to use Input parameter. use the below linki to get more details on it.

https://www.antaresanalytics.net/post/2018/09/11/power-bi-creating-user-input-variables

 

pranit828_0-1597277378219.png

 




PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors