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
Abhanshu97
Frequent Visitor

How to match two unrelated dates tables using DAX ?

We have two tables - Table A and Table B

Table A contains the column of Employee ID(EID) and Date of Joining(DOJ).

Table B contains the column of Dates(Date) only.

There is no relationship between two tables.

Please suggest me how do I match the two tables such that if we select date slicer from Table B then it would change the data of Row card containing count of EID ?

I have tried using Lookupvalue but it didn't work.

 

Any help would be appreciated!!

 

 

2 ACCEPTED SOLUTIONS
v-rzhou-msft
Community Support
Community Support

Hi @Abhanshu97 

You can try to build a measure to calculate the count of Employee ID in Table A based on the filter of unrelated Date table.

Table A:

1.png

Date Table:

Date = CALENDARAUTO()

They are unrelated.

3.png

If you want to select dates directly in date slicer, try this measure.

Measure = 
VAR _SelectValue = VALUES('Date'[Date])
VAR _Count = CALCULATE(COUNT('Table A'[Employee ID]),FILTER(ALL('Table A'),'Table A'[Date] in _SelectValue))
RETURN
_Count

By default, no selection in date slicer, result should return to 8.

2.png

In silcer I select 2021/05/10 and 2021/07/05, result should return to 3.

1.png

If you want to filter Table A by between function in unrelated date slicer, try this measure.

Measure 2 = 
VAR _RangeStart = MIN('Date'[Date])
VAR _RangeEnd = MAX('Date'[Date])
VAR _Count = CALCULATE(COUNT('Table A'[Employee ID]),FILTER(ALL('Table A'),AND('Table A'[Date]>=_RangeStart,'Table A'[Date]<=_RangeEnd)))
RETURN
_Count

By default:

1.png

Range between 2021/05/10 and 2021/07/05:

2.png

Best Regards,

Rico Zhou

 

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

Hello @v-rzhou-msft,

 

Thanks a ton, for your help. I really appreciate it.

View solution in original post

5 REPLIES 5
v-rzhou-msft
Community Support
Community Support

Hi @Abhanshu97 

You can try to build a measure to calculate the count of Employee ID in Table A based on the filter of unrelated Date table.

Table A:

1.png

Date Table:

Date = CALENDARAUTO()

They are unrelated.

3.png

If you want to select dates directly in date slicer, try this measure.

Measure = 
VAR _SelectValue = VALUES('Date'[Date])
VAR _Count = CALCULATE(COUNT('Table A'[Employee ID]),FILTER(ALL('Table A'),'Table A'[Date] in _SelectValue))
RETURN
_Count

By default, no selection in date slicer, result should return to 8.

2.png

In silcer I select 2021/05/10 and 2021/07/05, result should return to 3.

1.png

If you want to filter Table A by between function in unrelated date slicer, try this measure.

Measure 2 = 
VAR _RangeStart = MIN('Date'[Date])
VAR _RangeEnd = MAX('Date'[Date])
VAR _Count = CALCULATE(COUNT('Table A'[Employee ID]),FILTER(ALL('Table A'),AND('Table A'[Date]>=_RangeStart,'Table A'[Date]<=_RangeEnd)))
RETURN
_Count

By default:

1.png

Range between 2021/05/10 and 2021/07/05:

2.png

Best Regards,

Rico Zhou

 

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

Hello @v-rzhou-msft,

 

Thanks a ton, for your help. I really appreciate it.

Portrek
Resolver III
Resolver III

Hi Abhanshu97

 

Make a relationship between the tables, join the Date[date] and Date of joininid columns. By doing this the slicer will change your row card

 

Best regards

Thanks Portrek!

 

But here the problem is that, we can't create the relationship between tables. I mean we only have to use DAX to match the tables.

 

Is that be possible to do so with DAX?

Without relationships I find it very difficult to get. Good luck !

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.