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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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 Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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