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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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. 

Community Support
Community Support

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] )
        ALL ( postdatetable ),
        USERELATIONSHIP ( table[date], predatetable[date] )

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



Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors