cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kushalt1996
Frequent Visitor

Populate first value with the expanded column's value and rest with 0/null on merge query

I have two tables 

Table A - Has Product information (Product, Sub-Product Count)

Table B - Actually it's a sales table with (Sales Date, Brand/Product)

 

Requirement - I want third column on merge. But I only want to have third column to have values (no. of sub-product) to be populated for only first matching Product/Brand and rest to be '0' or null for the same Brand/Product.

 

The merge operation is applied based on 'Left Join' on column 'Brand' : Table B -> Table A 

 

values required.png

1 REPLY 1
NaveenGandhi
Continued Contributor
Continued Contributor

Hello @kushalt1996 

 

I have a solution that involves PQ and DAX. Please follow the below.

Sep 1:

Add index to your table - b  And create a custom column by using [Brand]&Text.From([Index]).NaveenGandhi_0-1685376464368.png

Step 2:

Merge Table-b with table - a and pull the Min of index from Table - b. Again create a custom column like above.NaveenGandhi_3-1685376590030.png

 

Step 3:
Close and Apply and use a lookup to pull the Sub Product count.

No of Sub Product = LOOKUPVALUE('Table- A'[Sub-Product count],'Table- A'[Custom],'Table - B'[Custom])
NaveenGandhi_4-1685376787241.png

 

Please let me know this solution is good with you and if you have any questions.
 
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors