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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
aglpr
Advocate II
Advocate II

Group Range of Date and Return a Label

Hello colleague,

 

Sorry for this stupid-but-simple question

 

How do I group the date range using DAX and return a value label?

 

Example : Range date of 1 Jan 2023 to 31 Jan 2023 will be labeled "A". Range date of 1 Feb 23 to 28 Feb 23 will be labeled "B", etc

 

I already have the date table in my dataset btw.

 

Thank you!

1 ACCEPTED SOLUTION

@aglpr 

Then it should be hard coded like

SWITCH (

TRUE ( ),

'Date'[Date] IN CALENDAR ( DATE ( 2023, 01, 03 ), DATE ( 2024, 01, 23 ) ), "A",

etc.

)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @aglpr 

you can create a calculated column the date table using switch statement 

SWITCH (

MONTH ( 'Date'[Date] ),

1, "A",

2, "B",

etc.

)

or perhaps you need to do that for Year-Month?

Hello Tamer,

 

Many thanks for your reply. What if the date is specific? (not limited only to the month)

 

For example 3 Jan 23 to 16 Feb 23 is "A", 17 Feb 23 to 21 Mar 23 is "B"

 

Thanks again!

@aglpr 

Then it should be hard coded like

SWITCH (

TRUE ( ),

'Date'[Date] IN CALENDAR ( DATE ( 2023, 01, 03 ), DATE ( 2024, 01, 23 ) ), "A",

etc.

)

Many thanks Tamer! It works now 🙂

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.