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! Request now

Reply
MYDATASTORY
Resolver I
Resolver I

Lookup table based on other table

Hi 

I have a quick question,

I have two separate tables, one table has dates and the other tables have dates and the Finacial year column and I want to do a lookup. I have connected the Purchase dates with the Calendar date, now I need to connect the Sales date with the Calendar Date so I can get the Financial year lookup.

Sales Table with two date columns

Sales IDPurchase DateSales DatesAmountSales Dates (Expected result)
101/04/202002/04/2020 $    10.00FY20-21
201/04/202003/04/2020 $    11.00FY20-21
302/04/202004/04/2020 $    12.00 
403/04/202005/04/2020 $    13.00 
504/04/202006/04/2020 $    14.00 
605/04/202007/04/2020 $    15.00 
706/04/202008/04/2020 $    16.00 
807/04/202009/04/2020 $    17.00 
908/04/202010/04/2020 $    18.00 
1009/04/202011/04/2020 $    19.00 
1110/04/202012/04/2020 $    20.00 
1211/04/202013/04/2020 $    21.00 
1312/04/202014/04/2020 $    22.00 
1413/04/202015/04/2020 $    23.00 
1501/04/197016/04/2020 $    24.00 
1602/04/197010/04/1970 $    25.00 
1703/04/197011/04/1970 $    26.00 
1804/04/197012/04/1970 $    27.00FY70-71
1905/04/197013/04/1970 $    28.00FY70-71
2006/04/197014/04/1970 $    29.00 
2107/04/197015/04/1970 $    30.00 
2208/04/197016/04/1970 $    31.00 
2309/04/197017/04/1970 $    32.00 
2410/04/197018/04/1970 $    33.00 
2511/04/197019/04/1970 $    34.00 
2613/04/202020/04/1970 $    35.00 
2701/04/197021/04/1970 $    36.00 
2802/04/197022/04/1970 $    37.00 
2903/04/197023/04/1970 $    38.00 
3004/04/197024/04/1970 $    39.00 
3105/04/197025/04/1970 $    40.00 
3206/04/197026/04/1970 $    41.00 
3307/04/197027/04/1970 $    42.00 
3408/04/197028/04/1970 $    43.00 
3509/04/197029/04/1970 $    44.00 
3610/04/197030/04/1970 $    45.00 
3711/04/197001/05/1970 $    46.00 

 

FY lookup 

Date FY
01/04/2020FY 20-21
02/04/2020FY 20-21
03/04/2020FY 20-21
04/04/2020FY 20-21
05/04/2020FY 20-21
06/04/2020FY 20-21
07/04/2020FY 20-21
08/04/2020FY 20-21
09/04/2020FY 20-21
10/04/2020FY 20-21
11/04/2020FY 20-21
12/04/2020FY 20-21
13/04/2020FY 20-21
01/04/1970FY 70-71
02/04/1970FY 70-71
03/04/1970FY 70-71
04/04/1970FY 70-71
05/04/1970FY 70-71
06/04/1970FY 70-71
07/04/1970FY 70-71
08/04/1970FY 70-71
09/04/1970FY 70-71
10/04/1970FY 70-71
11/04/1970FY 70-71
1 ACCEPTED SOLUTION

Hi, @MYDATASTORY , I tried both TREATAS and USERELATIONSHIP and both seem to work in your case; but the USERELATIONSHIP one is a bit tricky. You may refer to the attached file for more details.

FY.png

Nice weekend!


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

Hi, @MYDATASTORY , as info is limited, what I can do is to make a best guess and a possible solution is to resort to TREATAS func to establish a virtual relationship dedicated to such a lookup. The measure is like this,

FY Lookup = 
CALCULATE (
    MAX ( 'Data Table'[FY] ),
    TREATAS ( VALUES ( Sales[Date] ), 'Data Table'[Date] )
)

TREATAS.png 

Date column comes from Sales table.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

@CNENFRNL  Hi, Thanks for that.  I have used this, is working partially,  is not matching some of the dates. I am only getting one FY which is 19-20

For the below date, I would expect 

05/06/2020  ==>FY20-21

 

@MYDATASTORY If you attach a file with a bit more mockup data, especially a complete structure of data model, maybe I or other gurus here could come up with a better solution.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

@CNENFRNL @amitchandak 

Apologies not been clear  I have added the data, I have already calendar but the problem on my sales date table has two dates column, one I have connected with first date column then match the financial year but the second dates columns which are sales date can not be connected to date table as this is not allowed on Power BI, I have tried LookValue and User Relationship to get the second connection and this not working, here my  dummy data

Calendar FY lookup table start April

Date FY
01/04/2020FY 20-21
02/04/2020FY 20-21
03/04/2020FY 20-21
04/04/2020FY 20-21
05/04/2020FY 20-21
06/04/2020FY 20-21
07/04/2020FY 20-21
08/04/2020FY 20-21
09/04/2020FY 20-21
10/04/2020FY 20-21
11/04/2020FY 20-21
12/04/2020FY 20-21
13/04/2020FY 20-21
01/04/1970FY 70-71
02/04/1970FY 70-71
03/04/1970FY 70-71
04/04/1970FY 70-71
05/04/1970FY 70-71
06/04/1970FY 70-71
07/04/1970FY 70-71
08/04/1970FY 70-71
09/04/1970FY 70-71
10/04/1970FY 70-71
11/04/1970FY 70-71

 

Dummy Sales Date which we need to match FY on sales dates columns dates as we have connected the  Purchase date  column  with the Calendar  Date column

Sales IDPurchase DateSales DatesAmountFY??
101/04/202002/04/2020 $    10.00 
201/04/202003/04/2020 $    11.00 
302/04/202004/04/2020 $    12.00 
403/04/202005/04/2020 $    13.00 
504/04/202006/04/2020 $    14.00 
605/04/202007/04/2020 $    15.00 
706/04/202008/04/2020 $    16.00 
807/04/202009/04/2020 $    17.00 
908/04/202010/04/2020 $    18.00 
1009/04/202011/04/2020 $    19.00 
1110/04/202012/04/2020 $    20.00 
1211/04/202013/04/2020 $    21.00 
1312/04/202014/04/2020 $    22.00 
1413/04/202015/04/2020 $    23.00 
1501/04/197016/04/2020 $    24.00 
1602/04/197010/04/1970 $    25.00 
1703/04/197011/04/1970 $    26.00 
1804/04/197012/04/1970 $    27.00 
1905/04/197013/04/1970 $    28.00 
2006/04/197014/04/1970 $    29.00 
2107/04/197015/04/1970 $    30.00 
2208/04/197016/04/1970 $    31.00 
2309/04/197017/04/1970 $    32.00 
2410/04/197018/04/1970 $    33.00 
2511/04/197019/04/1970 $    34.00 
2613/04/202020/04/1970 $    35.00 
2701/04/197021/04/1970 $    36.00 
2802/04/197022/04/1970 $    37.00 
2903/04/197023/04/1970 $    38.00 
3004/04/197024/04/1970 $    39.00 
3105/04/197025/04/1970 $    40.00 
3206/04/197026/04/1970 $    41.00 
3307/04/197027/04/1970 $    42.00 
3408/04/197028/04/1970 $    43.00 
3509/04/197029/04/1970 $    44.00 
3610/04/197030/04/1970 $    45.00 
3711/04/197001/05/1970 $    46.00 

Hi, @MYDATASTORY , I tried both TREATAS and USERELATIONSHIP and both seem to work in your case; but the USERELATIONSHIP one is a bit tricky. You may refer to the attached file for more details.

FY.png

Nice weekend!


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@MYDATASTORY , Ideally you should have a date table with FY to be part of your date table. Not clear what is the issue.

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
1.Creating Financial Calendar - From Any Month
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calend...

examples

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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