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
Anonymous
Not applicable

DAX query with text field

Hello,

 

Can anyone help by correcting the DAX query below to pull a text field from one table to another?

 

The Staff Table demonstrates all staff members (identified by Username), and which team they belonged to (ServiceDisplayName) at a certain date (In Month). The Contact Table demonstrates which staff recorded a contact (indentified by ConsultationUsername) at a certain date (ConsultationMonth). Because staff have moved teams and performed multiple contacts the tables have been joined Many:Many on Username and ServiceDisplayName. Both of these fields are text based.

 

My problem is I can't find a suitable command to replace DISTINCTCOUNT below. It may be I need to write the formula in a totally different way, but hopefully below demonstrates what I'm trying to do. 

 

 

ESR-UsernameService = IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,04,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 04, 01)),
IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,05,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 05, 01)),
IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,06,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 06, 01)),
IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,07,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 07, 01)),
IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,08,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 08, 01)),
IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,09,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 09, 01)),
IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,10,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 10, 01)),
IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,11,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 11, 01)),
IF('Contact Table'[ConsultationMonth].[Date]=DATE(2019,12,01), CALCULATE(DISTINCTCOUNT('Staff Table'[ServiceDisplayName]), 'Staff Table'[In Month]=DATE(2019, 12, 01)),
BLANK())))))))))

 

 

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

Hi @Anonymous ,

 

If I understand you correctly, please try Merge Queries feature in Query Editor.

4.PNG

For more details please check the document below.

https://docs.microsoft.com/en-us/power-bi/desktop-shape-and-combine-data#combine-queries.

Here's my sample data and result would be show as below.

1.PNG

2.PNG

3.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

If I understand you correctly, please try Merge Queries feature in Query Editor.

4.PNG

For more details please check the document below.

https://docs.microsoft.com/en-us/power-bi/desktop-shape-and-combine-data#combine-queries.

Here's my sample data and result would be show as below.

1.PNG

2.PNG

3.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

To help you further I need pbix file. If possible please share a sample pbix file after removing sensitive information.

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.