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

View all the Fabric Data Days sessions on demand. View schedule

Reply
zakkyang
Frequent Visitor

POWER BI DAX: best solution of how not to duplicate to merge two tables and calculate the metric

 

I have the following 2 tables:

 
Table 1   
DateBrandSegmentDaily Click User
1/1/2020ASegment1100
1/1/2020ASegment2200
1/1/2020ASegment3454
1/1/2020ASegment4534
1/2/2020ASegment1546
1/2/2020ASegment2675
1/2/2020ASegment3876
1/2/2020ASegment4876
1/1/2020BSegment1987
1/1/2020BSegment254345
1/1/2020BSegment345425
1/1/2020BSegment443566
1/2/2020BSegment14786545
1/2/2020BSegment2453543
1/2/2020BSegment36545645
1/2/2020BSegment4654654

 

Table 2  
DateBrandTotal Daily Brand Population
1/1/2020A10000000
1/2/2020A20000000
1/1/2020B3000000000
1/2/2020B3100000000
 

 

The target metric calculation logic is in below: 

 
DateBrandSegmentDaily Click UserBrand PopulationBrand Penetration%
1/1/2020ASegment110010000000?
1/1/2020ASegment220010000000?
1/1/2020ASegment345410000000?
1/1/2020ASegment453410000000?
1/2/2020ASegment154620000000?
1/2/2020ASegment267520000000?
1/2/2020ASegment387620000000?
1/2/2020ASegment487620000000?
1/1/2020BSegment19873000000000?
1/1/2020BSegment2543453000000000?
1/1/2020BSegment3454253000000000?
1/1/2020BSegment4435663000000000?
1/2/2020BSegment147865453100000000?
1/2/2020BSegment24535433100000000?
1/2/2020BSegment365456453100000000?
1/2/2020BSegment46546543100000000?

The Brand Penetration Rate is calculated by Clicker Users/Total Brand Population.

It is tempting to use the dax below:

Total Click = SUM(table1[Daily Click User])
Total Brand = SUM(table2[Total Daily Brand Population]) 
Brand Penetration = [Total Click]/[Total Brand]\

However, I am worried that it will result in duplicated values when aggregating the daily click user by segments, the total brand population will also be duplicated.

My hope is to flexibly know the Brand Penetration Rate by segments slicer or overall.

 

So finally, we can see the trend visualization by either any segments or All.

zakkyang_4-1628529985250.png

Thank you.

 

 

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

Hi, @zakkyang ;

You could merge two tables in power query first ,and then create a measure.

1.merge two tables by two columns.

vyalanwumsft_0-1628733786544.png

2.create a measure.

Brand Penetration = 
VAR _sumclick =
    CALCULATE (
        SUM ( [Daily Click User] ),
        ALLEXCEPT ( Table1, Table1[Brand], Table1[Date] ))
RETURN
    DIVIDE(MAX ( [Table2.Total Daily Brand Population] ) ,_sumclick)

The final output is shown below:

vyalanwumsft_1-1628734269853.png

Best Regards,
Community Support Team_ Yalan Wu
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

1 REPLY 1
v-yalanwu-msft
Community Support
Community Support

Hi, @zakkyang ;

You could merge two tables in power query first ,and then create a measure.

1.merge two tables by two columns.

vyalanwumsft_0-1628733786544.png

2.create a measure.

Brand Penetration = 
VAR _sumclick =
    CALCULATE (
        SUM ( [Daily Click User] ),
        ALLEXCEPT ( Table1, Table1[Brand], Table1[Date] ))
RETURN
    DIVIDE(MAX ( [Table2.Total Daily Brand Population] ) ,_sumclick)

The final output is shown below:

vyalanwumsft_1-1628734269853.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors