Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

Help on dynamic axis based on slicer value

Hi. Kindly asking for help: I have a chart with x-axis as months. I want to show only 6 months worth of records here but it should be dependent on the selected slicer. ex: Selected on slicer is Sep'19 the chart should show Apr'19-Sep'19; but when we select Aug'19 on the slicer chart axis to show Mar'19-Aug'19. Hope you can assist. Thanks!

2 ACCEPTED SOLUTIONS
V-lianl-msft
Community Support
Community Support

Hi @Anonymous,

 

You may refer to the post below to create a disconnected table for your slicer and then create a measure based on that selection.

https://community.powerbi.com/t5/Desktop/Dynamically-changing-Months-based-on-X-axis-of-line-chart-based/m-p/823754 

 

Best Regards,

Liang 

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-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

First you should create a calendar table and use it as a slicer, then create a measure.

1. calendar table

 

DimDate = ADDCOLUMNS(CALENDAR("01/01/2018","31/12/2019"),"Month - Year", FORMAT([Date],"mm - yy"),"SortMonth",FORMAT([Date],"yyyymm"))

 

2.use it as a slicer

Capture1.PNG

3. create a measure

 

Sales last 6 months = 
CALCULATE (
    SUM ( Sales[Sales] ),
    FILTER (
        ALL ( Sales[Date] ),
        Sales[Date] <= MAX ( DimDate[Date] )
            && Sales[Date] >= EDATE ( MAX(DimDate[Date]), -6 )
    )
)

 

Here is the .pbix

 

Best Regards,

Liang

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-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

First you should create a calendar table and use it as a slicer, then create a measure.

1. calendar table

 

DimDate = ADDCOLUMNS(CALENDAR("01/01/2018","31/12/2019"),"Month - Year", FORMAT([Date],"mm - yy"),"SortMonth",FORMAT([Date],"yyyymm"))

 

2.use it as a slicer

Capture1.PNG

3. create a measure

 

Sales last 6 months = 
CALCULATE (
    SUM ( Sales[Sales] ),
    FILTER (
        ALL ( Sales[Date] ),
        Sales[Date] <= MAX ( DimDate[Date] )
            && Sales[Date] >= EDATE ( MAX(DimDate[Date]), -6 )
    )
)

 

Here is the .pbix

 

Best Regards,

Liang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks. Will surely try this.

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/
V-lianl-msft
Community Support
Community Support

Hi @Anonymous,

 

You may refer to the post below to create a disconnected table for your slicer and then create a measure based on that selection.

https://community.powerbi.com/t5/Desktop/Dynamically-changing-Months-based-on-X-axis-of-line-chart-based/m-p/823754 

 

Best Regards,

Liang 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks. will check this.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.