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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
adi_16
New Member

How to create different range of years in power bi dax?

Hi community!

 

I am stuck at one point in creating a different range of years. Suppose I have a year slicer and when any year is selected from it, it should create different ranges of years from the selected year to the maximum year present in the dataset.

 

Explaination-

 

If I select a year (eg 2018) from the slicer then it should be able to create a range something like this-

2018-19

2018-20

2018-21

2018-22 

If I select a year (eg 2020) from the slicer then it should be able to create a range something like this-

2020-21

2020-22

 

How it can be achived in dax? Any guidance and support would be very thankful.

 

Thanks in Advace!

4 REPLIES 4
Anonymous
Not applicable

Hi @adi_16 ,

 

Like this?

vmengzhumsft_0-1662974414400.png

 

when I choose 2018, the visual will appear data between 2018-2022;

when I choose 2020, it will change to between 2020-2022.

vmengzhumsft_1-1662974589552.png

You just need to directly create a slicer,and choose "between" as its expression. I don't think it needs to create dax.

vmengzhumsft_0-1662974866445.png

This is my pbix file, you can refer to it.

 

Best regards,

Community Support Team Selina zhu

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

 

 

Hi @Anonymous, Thank you for your response.

This is not what I am looking for. I need to get this different category of range.

amitchandak
Super User
Super User

@adi_16 , if you plan to create a table of columns based on the selected values that is not possible, You can only get measure if you already have a date or year table

 

You need have joined Date/Year table with you fact havin values

 

year FY

2018 2018-19

2019 2019-20

 

and independent table with years

 

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _min = maxx(allselected(Date1),Date1[Year])
var _max = Year(Today())
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Year] >=_min && 'Date'[Year] <=_max))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak , thank you for your response.

Can we create ranges of years as explained above? As I require the range in the visual representation.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.