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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
FrancoIVM
New Member

Multiply a filtered value by an unfiltered one in sumx

Hi,

I have a measure with the sales of the month for different products and I want to multiply it by another measure that contains the last purchase value of these products, the problem is that the sales are associated with (for example) a warehouse X1 and the purchase value is associated with where they were received, let's say is warehouse X2. So when I want to see the [sales]* [purchase value] it is blank because there is no purchase value associated with X1 (when im filtering by X1).

What I did was that the measure [purchase value] looked for the purchase value in all the warehouse with ALL as follows:
[Purchase value] = CALCULATE(
LASTNONBLANKVALUE('table'[date],
SUM('table'[values])),
ALL('table'[warehouse]))

That worked to show me the last purchase value of each product, but when multiplying it in the form:
[sales] * [purchase value]
Totals are multiplied because the calculation is not being done row by row.
But doing it with SUMX in the way:
SUMX ('table', [sales] * [purchase value])
The result is blank again as if [purchase value] was not looking up the values in all warehouses.

You could use ALL ('table' [warehouse]) like this:
CALCULATE (SUMX ('table', [sales] * [purchase value]), ALL ('table' [warehouse]))
But I'm interested in the sales being filtered through the selected warehouse.

So I wonder if there is a way that the [purchase value] is related to all the warehouse or if someone else comes up with another solution.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@FrancoIVM , if they are from the same table calculation should be done at the row-level

 

you can get a price like

[Purchase value] = CALCULATE(
LASTNONBLANKVALUE('table'[date],
SUM('table'[values])),
filter('table' , 'table'[warehouse] = earlier('table'[warehouse])))

 

or

 

[Purchase value] = CALCULATE(
LASTNONBLANKVALUE('table'[date],
SUM('table'[values])),
filter('table' , 'table'[item] = earlier('table'[item])))

 

or have the level to use values

CALCULATE (SUMX (values('table'[?]), [sales] * [purchase value]), ALL ('table' [warehouse]))

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@FrancoIVM , if they are from the same table calculation should be done at the row-level

 

you can get a price like

[Purchase value] = CALCULATE(
LASTNONBLANKVALUE('table'[date],
SUM('table'[values])),
filter('table' , 'table'[warehouse] = earlier('table'[warehouse])))

 

or

 

[Purchase value] = CALCULATE(
LASTNONBLANKVALUE('table'[date],
SUM('table'[values])),
filter('table' , 'table'[item] = earlier('table'[item])))

 

or have the level to use values

CALCULATE (SUMX (values('table'[?]), [sales] * [purchase value]), ALL ('table' [warehouse]))

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks you,

 

The last alternative works for me, 

CALCULATE (SUMX (values('table'[?]), [sales] * [purchase value]), ALL ('table' [warehouse]))

 

The ALL ('table' [warehouse]) was'nt necessary, when i used the Vale(table[items]) instead the table, the filters works fine.

 

I was a lot of time on this, so really ty!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors