cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
webportal Member
Member

Get value of column searching in between dates

I need to get the field "Name" from "Table1" in a calculated column in "Table2", like:

Table1:

Name | Date
ABC  | 5-jan-2017
ABC  | 7-jan-2017
DEF  | 8-may-2018
DEF  | 10-jun-2018

And Table2:

Date         | CalcColumn
6-Jan-2017   | ABC
25-may-2018  | DEF

The logic is the following: If Date in Table2 is within the minimum and maximum dates of Table1then get the name in Table1.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Get value of column searching in between dates

Hi @webportal

That's weird. Have a look at this file where I've run a quick test with the sample data you provided. Maybe there's something different from what you are doing?  

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Get value of column searching in between dates

Hi @webportal

Try this for your calculated column in Table2:

 

NewColumn =
CONCATENATEX (
    FILTER (
        ALL ( Table1[Name] );
        CALCULATE ( MIN ( Table1[Date] ) ) <= Table2[Date]
            && CALCULATE ( MAX ( Table1[Date] ) ) >= Table2[Date]
    );
    Table1[Name];
    ", "
)

This will also work if there is more than one name in Table1 meeting the requirement. If so, all names will be shown separated by commas.

webportal Member
Member

Re: Get value of column searching in between dates

Hello @AlB

The expression makes sense, but I'm getting an empty column, have no idea why.

Highlighted
Super User
Super User

Re: Get value of column searching in between dates

Hi @webportal

That's weird. Have a look at this file where I've run a quick test with the sample data you provided. Maybe there's something different from what you are doing?  

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 78 members 1,269 guests
Please welcome our newest community members: