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
Applicable88
Impactful Individual
Impactful Individual

Calculated table with summarizing of another table in a many to many relationship

Hello,

recently someone taught me that for summarizing columns from two different tables there is no need for related() function. 

But when I try to add addtional filter in it the syntax is greyed out. I have a Fact table and a materialtable. Both are connected via Material columns. They exist in a many to many relationship. 

 

Facttable:

OrderDateTypeStatusCategory Material
1234501.01.20215LLDLVRManuZZZ
1234602.01.20218ZLDLVRManuZZZ
1234703.01.2021888PRCCManuZZZ
1234804.01.2021888PRCCPlanZZZ
1234905.01.2021888PRCCPlanZZZ
1235006.01.2021888PRCCManuBB
1235107.01.2021888PRCCManuBB

 

Materialtable:

 

Material TotalAmountDateReserve
ZZZ200006.07.202111
ZZZ200006.07.202158
ZZZ200006.07.202133
ZZZ200006.07.202177
ZZZ200007.07.202155
ZZZ200008.07.202144
BB200009.07.202133
BB200010.07.202155


I first tried to just grouping the materialtable to one date and add sum of the reserve as an extra column:

Summarizedtable = ADDCOLUMNS(SUMMARIZE(Material, Material[Date],Material[TotalAmount],Material[Material]),"SumRes", calculate(sum(Material[Reserve])))

So now I have all materials grouped to one date. In the next step I actually tried to filter my new calculated table to following conditions which are based on another table, the fact table: Only show me the materials of orders where  Type = 888 or 8ZL, Status <> "DLVR", Category = "Plan"

So I added the conditions like these into the summarize part of the Summarizedtable:

'FACT'[Type] in {"888","8ZL"} ,NOT(CONTAINSSTRING('FACT'[Status],"DLVR")),'FACT'[CATEGORY] = "PLAN"))
But its all greyed out. 
How can I group the table and at the same time filter it?
Thank you very much in advance.
Best. 
1 ACCEPTED SOLUTION

Hi @Applicable88 

Your issue is circular dependencies in relationships. This issue is caused by you build the relationship from new table to Material Table. Your new table is a calcualted table by Dax depends on Materials table, so you builld relationship from it to Material Table may cause circular dependencies error. You can try to build the relationship from Material Table to new table. I have a test by your sample and it works.

Build relationship from new table to Material Table, we will get issue.

1.png

Build relationship from Material Table to new table, it works.

2.png

Here is a blog for circular dependencies, you may refer to it for more details.

 

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

3 REPLIES 3
Applicable88
Impactful Individual
Impactful Individual

@amitchandak thanks.

The formula works, but if I connect the new table to the material table I get "circle dependencies" , what can I do to avoid this?

 

Hi @Applicable88 

Your issue is circular dependencies in relationships. This issue is caused by you build the relationship from new table to Material Table. Your new table is a calcualted table by Dax depends on Materials table, so you builld relationship from it to Material Table may cause circular dependencies error. You can try to build the relationship from Material Table to new table. I have a test by your sample and it works.

Build relationship from new table to Material Table, we will get issue.

1.png

Build relationship from Material Table to new table, it works.

2.png

Here is a blog for circular dependencies, you may refer to it for more details.

 

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. 

amitchandak
Super User
Super User

@Applicable88 , You should be add those condition in new column you want to add from fact

'FACT'[Type] in {"888","8ZL"} ,NOT(CONTAINSSTRING('FACT'[Status],"DLVR")),'FACT'[CATEGORY] = "PLAN"))

 

or try calculatetable like

ADDCOLUMNS(SUMMARIZE(calculatetable(Material,

'FACT'[Type] in {"888","8ZL"} ,NOT(CONTAINSSTRING('FACT'[Status],"DLVR")),'FACT'[CATEGORY] = "PLAN"), Material[Date],Material[TotalAmount],Material[Material]),"SumRes", calculate(sum(Material[Reserve])))

 

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.