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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Relationships for Relative Date Filtering

I am trying to create a relationship between table A (has a date column) and table B (has a year column and a month column both  are in TEXT format and cannot be formated as date). Visuals on a page pull from tables A and B. I need a to establish a date relationship so I can set a relative date page filter to show last months data all of the time. I have tried several things, but to no avial. Does anyone has any suggestions?

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous ,

You can create a date like

 

Date = date([year], [month],1)

 or

Date = "01-" & [Month] & "-" &[Year] // change format Date if Month is format Jan or January 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Hi @Anonymous ,

 

If the 'Table B'[Month]  is like format "January, February ,,,",  you may use SWITCH function to change the value data format, then create calculated column [Date] like DAX below, change the data type to Date.

 

'Table B' [Month] = SWITCH('Table B' [Month] ,"January",1,"February",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)



Date=  'Table B' [Month] & "/01/" & 'Table B' [Year]

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous ,

You can create a date like

 

Date = date([year], [month],1)

 or

Date = "01-" & [Month] & "-" &[Year] // change format Date if Month is format Jan or January 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

This generates an error (same one I always recieve) "Cannot convert value '01--' of type Text to type Date.

 

Hi @Anonymous ,

 

If the 'Table B'[Month]  is like format "January, February ,,,",  you may use SWITCH function to change the value data format, then create calculated column [Date] like DAX below, change the data type to Date.

 

'Table B' [Month] = SWITCH('Table B' [Month] ,"January",1,"February",2,"March",3,"April",4,"May",5,"June",6,"July",7,"August",8,"September",9,"October",10,"November",11,"December",12)



Date=  'Table B' [Month] & "/01/" & 'Table B' [Year]

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

Daviejoe
Memorable Member
Memorable Member

This might help too

 

https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Table B is used to capture end of month data by year and facility. So, I have three years, 12 months per year, and eight facilities. The format of YYYY-MM does not create unique values and neither did a third table I created with unique values 2018 - 2020 as YYYY-MM.

Daviejoe
Memorable Member
Memorable Member

Are you not able, in Query Editor to convert the year and month into a date format?

 

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

Top Solution Authors