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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
markyochoa
Helper I
Helper I

Reference date from a calendar table in a custom column

Hello all,

 

Pretty sure this is a straight forward answer I just can't seem to figure it out.

 

I have a custom calendar table that is fairly standard practice. It's a single column table with a bunch of dates that I can use as reference in measures. That works fine with measures, but is it possible to do the same thing for columns? 

 

I have a historical dashboard with a table that has all the historical data, and a column called "Snapshot Date" that has the date of the snapshot. The data also has a column "Date Created" that has the date created of a document.

 

I wanted to create a column that says if it was created within a week of a certain date in history. So something along the lines of:

 

IsWithinAWeek = IF(DATEDIFF(Table[Date Created], [SelectedDate], WEEK()) == -1, "Last Week")

 

Where [SelectedDate] = MAX(Calendar[Date])

 

This doesn't seem to be working. The actual implementation is a bit more complex that incorporates "Last week", "this week", and "next week", but this is the gist of it. 

 

EDIT: 

 

I forgot to mention, I'm doing this because I want the user to be able to use the calendar UI to pick a single date. So I'm doing the trick where you have a date slicer set to "Before", and I'm blocking the "After" side of the date picker and using MAX() to get the date. 

 

As such:

markyochoa_0-1694818179319.png

 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @markyochoa 
If I understand you correctly and you want to do something "on the fly" and make some calculations as a calculated column based on user selection this is not possible.

If it is something else please share your data table and desired result.

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

View solution in original post

2 REPLIES 2
markyochoa
Helper I
Helper I

Yeah I was afraid it wouldn't be possibe. Thanks. 

Ritaf1983
Super User
Super User

Hi @markyochoa 
If I understand you correctly and you want to do something "on the fly" and make some calculations as a calculated column based on user selection this is not possible.

If it is something else please share your data table and desired result.

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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.