Forum Discussion

Yian's avatar
Yian
Frequent Visitor
3 years ago
Solved

Measure total incorrect

Dear Community,

 

I have the following measure written for a calculation involving two columns from two tables with a many-to-many relationship.

 

The first table is the 'Transactions Breakdown Table'. This table comprises various expenses incurred for each portfolio. Some portfolios have only one expense (a single row of data), while others have multiple expenses (multiple rows of data for one item). Each expense has a corresponding account number. 

PortfolioExpenseAccount number
abc1100123
abc1100124
abc1100125
abc21100123
abc22100123
abc23100123
abc24100123
abc25100123
abc26100123
abc27100123
abc28100123
abc2910000123

 

The second table is the 'Ownership mapping' table. It displays the percentage share of each client's expenses for each portfolio. A value of 1 represents 100%, and 0.04 signifies 4%. Some portfolios have only one client, while others have more than one.

Client OwnershipClientPortfolio
1Maryabc1
1Lilyabc2
1Lilyabc3
1Lilyabc4
1Johnabc5
1Johnabc6
1Johnabc7
1Maryabc8
1Henryabc9
0.04Lilyabc10
0.025Johnabc10
0.35Jessicaabc10
0.25Zoeyabc10
0.011Aberleneabc10
0.183Joannaabc10
0.076Maggieabc10
0.065Maryabc10

 

For each expense in every portfolio, I would like to calculate the share of the expense for each corresponding client. However, when I use this measure as values in a matrix table, the grand row total is adding up correctly but the row values are not correct. I went on to create measure 2, which gives me correct row values but incorrect grand row total. Appreciate if anyone could provide any help. Thanks in advance!

 

Measure =
var net_amt = CALCULATE(SUM('Transactions Breakdown'[Expense]))  
var cnt_own = CALCULATE(MAX('Ownership mapping'[Client Ownership]))  
return net_amt * cnt_own

Measure 2 =
SUMX(
    SUMMARIZE(
        'Ownership mapping',
        'Ownership mapping'[Client],
        'Ownership mapping'[Portfolio],
        "TotalOwnership", SUM('Ownership mapping'[Client Ownership])
    ),
    [Measure]
)


  • Hi, Yian 

     

    You can try the following methods.

    Measure 3 = IF(HASONEVALUE('Ownership mapping'[Client]),[Measure 2],[Measure])

    Is this the result you expect? If not, please provide the output you expect.

     

    Best Regards,

    Community Support Team _Charlotte

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

3 Replies

  • Yian , multiplication needs to be done at row level and then needs to be summed up. if not possible then use common columns

     

    preferably from common dimension/on visual columns

     

    Sumx(Values(Dim[Column]), CALCULATE(SUM('Transactions Breakdown'[Total]) * MAX('Ownership mapping'[Client Ownership])) )

     

    Use summarize for more than one column

    • Yian's avatar
      Yian
      Frequent Visitor

      Hi,

       

      Thanks for the reply. But the solution didn't work out. I just edited my original post and added more information. Please take a look. Thanks very much!

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, Yian 

     

    You can try the following methods.

    Measure 3 = IF(HASONEVALUE('Ownership mapping'[Client]),[Measure 2],[Measure])

    Is this the result you expect? If not, please provide the output you expect.

     

    Best Regards,

    Community Support Team _Charlotte

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