Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
santoshhmsam50
Frequent Visitor

hierarchy filter based on the tables that are with many to many relationship

I have a table with  a LIKE 

CUSTOMER 
LABCCA

 

20

LCBA 

50

LDCC 

 

 

And tabbel B as same format 

abcsaleSession
LCBA 50032443
LDBC 111343
LA CA2234324
LD CA333Need Help34434

I want to create the  visulization with the  filterwith Hierarchy on a, b,c  th Show and Tellat can cover both the table  , looks to be the data model and DAX support

@DA @dax @rajendra 

@Ritaf1983

Ritaf1983

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @santoshhmsam50 ,

 

You need to create the following relational columns in each table and then create hierarchical tables. Then apply the following formula to the metric table.

CombinedKey = [a] & "|" & [b] & "|" & [c]
HierarchyTable = DISTINCT(
    UNION(
        SELECTCOLUMNS('TableA', "a", [a], "b", [b], "c", [c]),
        SELECTCOLUMNS('TableB', "a", [a], "b", [b], "c", [c])
    )
)

vkongfanfmsft_0-1719539871760.png

SumCustomer = 
CALCULATE(
    SUM(TableA[CUSTOMER]),
    TREATAS(
        VALUES(HierarchyTable[CombinedKey]),
        TableA[CombinedKey]
    )
)
SumSales = 
CALCULATE(
    SUM(TableB[sale]),
    TREATAS(
        VALUES(HierarchyTable[CombinedKey]),
        TableB[CombinedKey]
    )
)

vkongfanfmsft_1-1719539934555.png

 

Best Regards,
Adamk Kong

 

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

Thanks a lot for  solving and explaining it in such a simple way 🙂

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @santoshhmsam50 ,

 

You need to create the following relational columns in each table and then create hierarchical tables. Then apply the following formula to the metric table.

CombinedKey = [a] & "|" & [b] & "|" & [c]
HierarchyTable = DISTINCT(
    UNION(
        SELECTCOLUMNS('TableA', "a", [a], "b", [b], "c", [c]),
        SELECTCOLUMNS('TableB', "a", [a], "b", [b], "c", [c])
    )
)

vkongfanfmsft_0-1719539871760.png

SumCustomer = 
CALCULATE(
    SUM(TableA[CUSTOMER]),
    TREATAS(
        VALUES(HierarchyTable[CombinedKey]),
        TableA[CombinedKey]
    )
)
SumSales = 
CALCULATE(
    SUM(TableB[sale]),
    TREATAS(
        VALUES(HierarchyTable[CombinedKey]),
        TableB[CombinedKey]
    )
)

vkongfanfmsft_1-1719539934555.png

 

Best Regards,
Adamk Kong

 

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

 

Thanks a lot for  solving and explaining it in such a simple way 🙂

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.