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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
jbradley16
Frequent Visitor

Weighted Average Held By Constant Weight

Hello all, I'm attempting to compare two values of Weighted Average Price over a pre and post date set. The formulas I currenlty have are setup like:

 

Post Period Weighted Avg: sumx(table, quantity * price)/sum(quantity)

Pre Period Weighted Avg: calculate('formula above', all(postdatetable),userelationship(table,predatetable)

 

The quantity in the post period needs to be held to the same constant value as the pre period quantity. when I attempt to use something like:

 

Constant WAP: sumx(PostPeriodWAP*calculate(sum(quantity),all(postdatetable),userelationship(table,predatetable)))/calculate(sum(quantity),all(postdatetable),userelationship(table,predatetable))

 

I get some crazy numbers. How do I go about holding this pre-period constant? The pre period is set to a slicer value to allow the end user to custom set their pre and post period. 

1 REPLY 1
Anonymous
Not applicable

HI @jbradley16,

 

I can't understand your formula, can you please explain more about these with some sample data and expected result?

 

If you mean nested measures, you can try to use below formula if it suitable for your requirement:

 

Pre Period Weighted Avg =
VAR temp =
    SUMX ( ALLSELECTED ( table ), [quantity] * [price] )
        / SUM ( table[quantity] )
RETURN
    CALCULATE (
        temp,
        ALL ( postdatetable ),
        USERELATIONSHIP ( table[date], predatetable[date] )
    )

Constant WAP =
VAR temp =
CALCULATE (
SUM ( table[quantity] ),
ALL ( postdatetable ),
USERELATIONSHIP ( table[date], predatetable[date] )
)
RETURN
SUMX ( ALLSELECTED ( table ), [Pre Period Weighted Avg] * temp )
/ temp

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.