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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mizaskun
Helper II
Helper II

"From-To" date table to date table by year

Good morning,

I have a table with user regions from a date to a date.

USER  |  REGION  |  FROM  |  TO
A  |  EUROPE  |  20190101  |  99991231

A  |  INDIA  |  20190101  |  20201231

 

I need to join the table by year and user. Thus, I am trying to come up with a way to convert this table to a table by year:

USER  |  REGION  |  YEAR

A  |  EUROPE  |  2019

A  |  EUROPE  |  2020

A  |  EUROPE  |  2021

A  |  INDIA  |  2019

A  |  INDIA  |  2020

 

How could I do this? Is there any way to join the first table by FROM and TO? Table A inner join Table B on A.User = B.User and A.From <= B.Date and A.To > B.Date. I do not know how to join this way in Power BI.

 

Thank you so much!

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @mizaskun 

 

There are ways to do it, I don't have your TableB, pretend use Year, use User and Region to do Merge, then check the year

Vera_33_0-1625106598021.png

[YEAR]>=Date.Year( [TableA][FROM]{0})
and
[YEAR]<=Date.Year( [TableA][TO]{0})

Or go to your TableA, convert From to To as a list, then Merge two tables, check the if date (in number format) in the list

Vera_33_1-1625106655883.png

{Number.From([FROM])..Number.From([TO])}

 

View solution in original post

1 REPLY 1
Vera_33
Resident Rockstar
Resident Rockstar

Hi @mizaskun 

 

There are ways to do it, I don't have your TableB, pretend use Year, use User and Region to do Merge, then check the year

Vera_33_0-1625106598021.png

[YEAR]>=Date.Year( [TableA][FROM]{0})
and
[YEAR]<=Date.Year( [TableA][TO]{0})

Or go to your TableA, convert From to To as a list, then Merge two tables, check the if date (in number format) in the list

Vera_33_1-1625106655883.png

{Number.From([FROM])..Number.From([TO])}

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors