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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum Totals for the Products of multiple Measures based on Single Column, with multiple Filters

Hi,

 

I have two measures (Price & Volume) that both do a sum on the same table and same columns but based on different filters on that specific table. I also have a measure (EURTotal) that multiplies these two measures. Currently it also multiplies the totals, however, I want it to SUM per period (YearMonth). These periods come from a separate Calendar table, linked to the table 'FACT'.

 

The current (simplified) dataset is used:

Sample data, Table 'FACT'

DateSubjectQuantity_TypeQuantity
2020-01-01TBVolume10
2020-02-01TBVolume200
2020-03-01TBVolume30
2020-04-01TBVolume70
2020-01-01TBPrice2
2020-02-01TBPrice5
2020-03-01TBPrice4
2020-04-01TBPrice3

 

Measure 'Price':

 

 

Price =
CALCULATE(
    SUM('FACT'[Quantity]),
    FILTER('FACT', 'FACT'[Subject] = "TB"),
    FILTER('FACT', 'FACT'[Quantity_Type] = "Price")
    )

 

 

 

And 'Volume':

 

 

Volume =
CALCULATE(
    SUM('FACT'[Quantity]),
    FILTER('FACT', 'FACT'[Subject] = "TB"),
    FILTER('FACT', 'FACT'[Quantity_Type] = "Volume")
    )

 

 

 

By simply multiplying I get, obviously, not a SUM in the total column, but a PRODUCT of the two SUMS. As you can see here:

 

Current result:

DateVolumePriceVol*Price
2020-01-0110220
2020-02-0120051000
2020-03-01304120
2020-04-01703210
Total310144340.00

 

What I tried is to use SUMX, but somehow multiplying SUMX * SUMX it gives the exact same result as SUM * SUM.

 

Expected result:

DateVolumePriceEURTotal
2020-01-0110220
2020-02-0120051000
2020-03-01304120
2020-04-01703210
Total310141350.00

 

What I specifically tried is the following:

 

 

EURTotal =
CALCULATE(
    SUMX('FACT'[Quantity]),
    FILTER('FACT', 'FACT'[Subject] = "TB"),
    FILTER('FACT', 'FACT'[Quantity_Type] = "Price")
    )
*
CALCULATE(
    SUMX('FACT'[Quantity]),
    FILTER('FACT', 'FACT'[Subject] = "TB"),
    FILTER('FACT', 'FACT'[Quantity_Type] = "Volume")
    )

 

 

 

This doesn't work, but I don't see how I could get it in a working SUMX format like the following, for instance:

EURTotal = SUMX (FACT,

FACT[Quantity] --but then a filter here on Price

* FACT[Quantity] --but then a filter here on Volume

)

which I found here: https://www.burningsuit.co.uk/blog/2018/07/dax-is-the-total-row-in-a-table-giving-you-grief/

 

Any suggestions?

 

Kind regards,

Igor

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Have you tried using "pivot column" in the query editor?

V-lianl-msft_1-1603437389355.png

 

V-lianl-msft_0-1603437360073.png

Then try this measure:

Measure = CALCULATE(SUMX(VALUES('Table'[Date]),CALCULATE(SUM('Table'[Price])*SUM('Table'[Volume]))))

V-lianl-msft_2-1603437940078.png

Sample .pbix

 

Best Regards,
Liang
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

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Have you tried using "pivot column" in the query editor?

V-lianl-msft_1-1603437389355.png

 

V-lianl-msft_0-1603437360073.png

Then try this measure:

Measure = CALCULATE(SUMX(VALUES('Table'[Date]),CALCULATE(SUM('Table'[Price])*SUM('Table'[Volume]))))

V-lianl-msft_2-1603437940078.png

Sample .pbix

 

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

amitchandak
Super User
Super User

@Anonymous , Try measure like

sumx(summarize(Table, Table[date], table[Subject], "_1" ,[price] , "_2",[volume]),[_1]*[_2])

Anonymous
Not applicable

Thanks for the quick response!

 

Unfortunately, I get the exact same result. I used this measure to try it out:

EURTotal =
    SUMX(
    SUMMARIZE('FACT', 
        'DIM Kalender'[Datum], --same result as 'FACT'[Date]
        'FACT'[Subject], 
        "_1", [Volume],
        "_2", [Price]),
    [_1]*[_2])

So the Total still has the value of the multiplication of the Total Volume * Total Price.

 

Kind regards,

Igor

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.