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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
monojchakrab
Resolver III
Resolver III

multiply two columns from two tables having many-to-many cardinality

I have two tables (screengrab from relationships attached) but connected with a many-to-many cardinality. 

 

I need to multiple the [ShippedQty] from the #Table[Amazon YTD] with the [MPU] column from #Table[configuration summary]

 

But neither RELATED not RELATEDTABLE is working, most certainly because of the M2M cardinality.

 

relationship summaryrelationship summary

Is there any workaround for this?

1 ACCEPTED SOLUTION

@monojchakrab 
IN this case you can use

=
SUMX (
    Table1,
    SUMX ( RELATEDTABLE ( Table2 ), Table1[ColumnName] * Table2[ColumnName] )
)

View solution in original post

8 REPLIES 8
monojchakrab
Resolver III
Resolver III

Thanks @tamerj1 .

I am actually trying to write a measure and use that in a card visual. If I can multiple these two columns it will give me the total qty sold, which is a very important measure for me for this report.

I have tried to write the same code as a measure - it does not work .

But thanks anyways for the quick response

@monojchakrab 
IN this case you can use

=
SUMX (
    Table1,
    SUMX ( RELATEDTABLE ( Table2 ), Table1[ColumnName] * Table2[ColumnName] )
)

That worked @tamerj1 ...

But I think its somehow giving the wrong result but there is no error with the formula. Thanks.

I think the 2nd nested iterator is playing wonky : If I do a sumproduct in excel, I am getting 4383 units (which is correct), whereas thru' this formula, I am getting a figure of 284.1 K, which is incorrect.

Any idea why this could be happening?

Also, If I try using LOOKUPVALUE, to pull in Table1[required column] into Table2, it is giving an error

@monojchakrab 
Is it possible to provide sample data and the expected result based on it?

TitleMPUActiveFormSize
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11SteviaSachets100 count
TitleShipped Quantity
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 50 Sachets, Pack of 51
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachets - Pack of 11
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 50 Sachets, Pack of 31
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 100 Sachets, Pack of 41
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 100 Sachets, Pack of 21
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 50 Sachets, Pack of 31
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 50 Sachets, Pack of 31
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 50 Sachets, Pack of 51
Equal Sweetener, Sugar Free, Zero Calorie, Calorie Control, 100 Sachets, Pack of 61
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 100 Sachets, Pack of 61
Equal Stevia Natural Sweetener, Sugar Free, 50 Sachets - Pack of 21
Equal Sweetener, Sugar Free, Zero Calorie, Calorie Control, 300 Tablets, Pack of 21
Equal Sweetener, Sugar Free, Zero Calorie, Calorie Control, 100 Sachets, Pack of 61
Equal Sweetener, Sugar Free, Zero Calorie, Calorie Control, 100 Sachets, Pack of 21
Equal Sweetener, Sugar Free, Low Calories, Sugar Control, 100 Sachets, Pack of 31
Equal Sweetener, Sugar Free, Zero Calorie, Calorie Control, 100 Sachets, Pack of 61

 

What I want is as follows :

 

Multiply the MPU from from Table 1 for every title matching in 2nd table with the shipped qty from table 2 and return the total sum of this multiplication.

Does that work for you?

Hi @monojchakrab 
Sorry for thr late reply 
The tilte in table1 has no title match from table2. Please provide relevant sample of data. Thank you.

In fact the Title column in Table1 references the same column in Table 2 - so they are identical actually.

However, I am copying the table again ;

TitleMPU
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11
Equal Stevia Natural Sweetener, Sugar Free, 100 Sachet, Pack of 11

Not sure if this works for you...Is there a way I can send over the PBIX file itself and you can check out the model?

tamerj1
Super User
Super User

Hi @monojchakrab 

Assuming that you are creating a calculated column in Table1 then

SUMX (

RELATEDTABLE ( Table2 ),

Table1[ColumnName] * Table2[ColumnName]

)

Helpful resources

Announcements
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.