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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Sergiy
Resolver II
Resolver II

Get values from unrelated table.

Hi,

 

There are two table. They are unrelated.

- Table "Groups"

- Table "MyCalendar"

 

I need to add two calculated columns to MyCalendar. The values for these columns have to be retrieved from Groups. The condition upon which the retrieval has to be done is that MyCalendar[Date] value has to be between Groups[StartDate] and Groups[EndDate].

 

What DAX code for these calculated columns could be?

I would be glad to be guided.

 

I made a sample with data:

https://www.dropbox.com/s/10mwguj9y5vmic0/GetValuesFromUnrelatedTable.pbix?dl=0

 

Dates.png

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@Sergiy ,

 

You can create two calculate columns based on table 'MyCalendar' using dax below:

GroupID = 
VAR CurrentDate = MyCalendar[Date]
RETURN
CALCULATE(MAX(Groups[Id]), FILTER(Groups, Groups[StartDate] <= CurrentDate && Groups[EndDate] >= CurrentDate))

GroupName = 
VAR CurrentDate = MyCalendar[Date]
RETURN
CALCULATE(MAX(Groups[Name]), FILTER(Groups, Groups[StartDate] <= CurrentDate && Groups[EndDate] >= CurrentDate))

Capture.PNG 

 

Community Support Team _ Jimmy Tao

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-yuta-msft
Community Support
Community Support

@Sergiy ,

 

You can create two calculate columns based on table 'MyCalendar' using dax below:

GroupID = 
VAR CurrentDate = MyCalendar[Date]
RETURN
CALCULATE(MAX(Groups[Id]), FILTER(Groups, Groups[StartDate] <= CurrentDate && Groups[EndDate] >= CurrentDate))

GroupName = 
VAR CurrentDate = MyCalendar[Date]
RETURN
CALCULATE(MAX(Groups[Name]), FILTER(Groups, Groups[StartDate] <= CurrentDate && Groups[EndDate] >= CurrentDate))

Capture.PNG 

 

Community Support Team _ Jimmy Tao

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

@v-yuta-msft ,

Thank you!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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