Forum Discussion
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
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))
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.
2 Replies
- v-yuta-msft
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))
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.
- Sergiy
Resolver II
Thank you!