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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
sajal161292
Helper V
Helper V

To create groups on date table

Hi,

 

I have  a calendar table as described below:

 

calendar.PNG

 

I would like to create groups on it like :

  if calendar[date] = today  then "0 day"

else if calendar[date] between today+1 and today+10 then "1-10 days"

else if calendar[date] between today+11 and today+20 then "11-20 days"

else if calendar[date] between today+21 and today+30 then "21-30 days"

 

and so on..

 

I am trying to use the switch over here but it is not working:

 

Column =
var x = today()
var y = DATESBETWEEN('Calendar'[new_date],x,x+11)
var z = DATESBETWEEN('Calendar'[new_date],y,y+11)
return SWITCH('Calendar'[new_date]=X,"0 DAY",'Calendar'[new_date]=y ,"1-10 days"))

 

 

Could you please help me in achieving this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Try this:

 

Column = 
VAR diff = Calendar[Date] - TODAY()
RETURN
    SWITCH(TRUE(),
        diff < 0, BLANK(),
        diff = 0, "0 days",
        diff <= 10, "1-10 days",
        diff <= 20, "11-20 days",
        diff <= 30, "21-30 days",
        "> 30 days"
    )

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Try this:

 

Column = 
VAR diff = Calendar[Date] - TODAY()
RETURN
    SWITCH(TRUE(),
        diff < 0, BLANK(),
        diff = 0, "0 days",
        diff <= 10, "1-10 days",
        diff <= 20, "11-20 days",
        diff <= 30, "21-30 days",
        "> 30 days"
    )

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.