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

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

Reply
Anonymous
Not applicable

Create a column that returns a value between dates

Hi there,

I am trying to create a "Generation" Column based on date ranges. I am having trouble writing a formula that says "if date >= 1/1/27 and date <= 12/31/37 then "Generation 1" else if "if date >= 1/1/38 and date <= 12/1/48 then "Generation 2 " ..... These are not the actual date ranges but you get what I mean. The end goal is to create a filter for my report so people can choose from a list of generations.

I would love some help or guidance with this and some suggestions as to the best way I can do this. 

 

Thank you so much.

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@Anonymous try something like this:

 

Gen Column = 
VAR __date = YourTable[YourDate]
RETURN
SWITCH ( TRUE(),
  __date >= DATE ( 2027,1, 1 ) && __date <= DATE ( 2037,12, 31 ), "Gen 1",
  __date >= DATE ( 2038,1, 1 ) && __date <= DATE ( 2048,12, 31 ), "Gen 2",
  "Gen other"
)

 

 

Follow us on LinkedIn

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

parry2k
Super User
Super User

@Anonymous it should be something like this:

 

Gen Column = 
VAR __year =  YourTable[YourYearColumn] )
RETURN
SWITCH ( TRUE(),
  __year >= 2001, "Gold",
  __year >= 1977, "Silver",
  __year >= 1962, "Bronze",
  "Others"
)

 

Follow us on LinkedIn

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@Anonymous it should be something like this:

 

Gen Column = 
VAR __year =  YourTable[YourYearColumn] )
RETURN
SWITCH ( TRUE(),
  __year >= 2001, "Gold",
  __year >= 1977, "Silver",
  __year >= 1962, "Bronze",
  "Others"
)

 

Follow us on LinkedIn

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Once again, thank you!!!!

parry2k
Super User
Super User

@Anonymous not sure what you mean by yyyy format, do you have only year value in the column?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi there, 

Yes, I have a column that has class years (2001, 1976, 1981, etc) and I want to create a similar formula that says if between 2001 - 2020 then "gold", if between 1976 - 1962, "Bronze", etc.  

 

They are currently formatted as whole numbers even tho they are years.

 

What additional information can I provide?

parry2k
Super User
Super User

@Anonymous try something like this:

 

Gen Column = 
VAR __date = YourTable[YourDate]
RETURN
SWITCH ( TRUE(),
  __date >= DATE ( 2027,1, 1 ) && __date <= DATE ( 2037,12, 31 ), "Gen 1",
  __date >= DATE ( 2038,1, 1 ) && __date <= DATE ( 2048,12, 31 ), "Gen 2",
  "Gen other"
)

 

 

Follow us on LinkedIn

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi There- this absolutely worked! May I ask how I would create the same formula using a date that is YYYY? In my dataset it's formatted as a Whole Number. It got wonky when I tried to convert it to a YYYY date format.  Is there a way to create a "Alum definition" column using YYYY ranges? Thank you so much!

Anonymous
Not applicable

This worked beautifully! Thank you so much!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.