web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / "Run a query against a...
Power Automate
Unanswered

"Run a query against a dataset" - join and filter two tables with Many-to-Many relationship

(0) ShareShare
ReportReport
Posted on by 9

I am facing an issue with a DAX query while using the "Run a query against a (Power BI) dataset" action in Power Automate. My dataset contains two tables, let's call them TableA and TableB, which are connected through a Many-to-Many relationship. The relationship is based on a key named ParentID in TableA and ItemID in TableB. I need help in writing a DAX query that returns a summarized version of these tables with specific columns, including those with empty or missing values. So that I can then filter these. Either directly in the query on for example TenantID =1 or after the query in a new action.

 

Here's a more detailed version of my tables:

 

TableA:

ParentID-TenantID-Quantity-Field1-Field2

1A10  
2A20Value1Value2
3B30Value3 

TableB:

ItemID-TenantID-Carrier-StorageLocation-Field3

1AC1L1Value4
2AC1L1Value5
3BC2L2

 

I need to write a DAX query that returns the following result:

 

ParentID-TenantID-Quantity-Field1-Field2-Carrier-StorageLocation-Field3

1A10  C1L1Value4
2A20Value1Value2C1L1Value5
3B30Value3 C2L2 

 

I tried the following DAX query, but it didn't work as expected:

EVALUATE
SUMMARIZECOLUMNS(

'TableA'[ParentID],
'TableA'[TenantID],
'TableA'[Quantity],
'TableA'[Field1],
'TableA'[Field2],
"Carrier", MAX('TableB'[Carrier]),
"StorageLocation", MAX('TableB'[StorageLocation]),
"Field3", MAX('TableB'[Field3])

)


This was the only solution that really outputs the contents from the other table without error, but the assignment to the respective items is no longer correct! 

 

I also tried using the RELATEDTABLE function, but it resulted in an error.

 

1. What is wrong with my DAX query, and how can I fix it to handle empty or missing values?

2. What is the correct way to use the RELATEDTABLE function in this scenario, considering the different key names (ParentID and ItemID) for the Many-to-Many relationship?

3. Is there an alternative way to achieve the desired result using DAX or any other approach within Power Automate, given the constraints of the relationship and the presence of empty fields?

 

 

I appreciate any assistance you can provide. Thank you in advance!

Best regards,

Patrick

Categories:
I have the same question (0)
  • Verified answer
    patrickgb Profile Picture
    9 on at

    I got the solution, the Filter is optional but it works:


    EVALUATE

    FILTER(

    SUMMARIZECOLUMNS(

    'TableA'[ParentID],
    'TableA'[TenantID],
    'TableA'[Quantity],
    'TableA'[Field1],
    'TableA'[Field2],
    "Carrier", MAXX(RELATEDTABLE('TableB'), 'TableB'[Carrier]),
    "StorageLocation", MAXX(RELATEDTABLE('TableB'), 'TableB'[StorageLocation]),
    "Field3", MAXX(RELATEDTABLE('TableB'), 'TableB'[Field3])

    ),
    'TableA'[TenantID] = "@{triggerBody()['text']}"

    )

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard