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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
gauravnarchal
Post Prodigy
Post Prodigy

Calculated Column

Hello - I want to add two columns in my calendar table to mark

 

  1. Yesterday was the "previous day" and the current date is "today".
  2. The current date is "today" and all previous dates are "previous dates" and all future dates are "future dates".

Thanks

 

2 ACCEPTED SOLUTIONS
AlexisOlson
Super User
Super User

A simple switching column should do the trick but it will require you to refresh your model every day since today changes.

 

DateCategory =
SWITCH (
    TRUE (),
    DimDate[Date] = TODAY (), "today",
    DimDate[Date] = TODAY () - 1, "previous day",
    DimDate[Date] < TODAY (), "previous dates",
    DimDate[Date] > TODAY (), "future dates"
)

View solution in original post

v-zhangti
Community Support
Community Support

Hi, @gauravnarchal 

 

  1. Create a new calendar table, assuming that these are the current dates.

 

Date = 
CALENDAR ( DATE ( 2021, 10, 01 ), DATE ( 2021, 10, 15 ) )

 

vzhangti_0-1637117236124.png

 

   2. Create two new columns to represent previous dates and future dates respectively.

 

Previous day = 
DATEADD ( 'Date'[Today], -1, DAY )
Future dates = 
DATEADD ( 'Date'[Today], +1, DAY )

 

vzhangti_1-1637117293805.png

 

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @gauravnarchal 

 

  1. Create a new calendar table, assuming that these are the current dates.

 

Date = 
CALENDAR ( DATE ( 2021, 10, 01 ), DATE ( 2021, 10, 15 ) )

 

vzhangti_0-1637117236124.png

 

   2. Create two new columns to represent previous dates and future dates respectively.

 

Previous day = 
DATEADD ( 'Date'[Today], -1, DAY )
Future dates = 
DATEADD ( 'Date'[Today], +1, DAY )

 

vzhangti_1-1637117293805.png

 

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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

AlexisOlson
Super User
Super User

A simple switching column should do the trick but it will require you to refresh your model every day since today changes.

 

DateCategory =
SWITCH (
    TRUE (),
    DimDate[Date] = TODAY (), "today",
    DimDate[Date] = TODAY () - 1, "previous day",
    DimDate[Date] < TODAY (), "previous dates",
    DimDate[Date] > TODAY (), "future dates"
)

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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