Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
Hoping for some help as I know what I want to do, but don't know how to do it.
Below are the two visualizations I am working with. The table on the left is out of stock and on the right side is the demand for those item, both determined by the date slicers. DaysOutofStock, AVGSales, AmountM and quantityM are all measures. Right now AVGSale on Out of Stock visualization is just returning the total AVGSale and not AVGSale based on Location ID (Internal ID__2).
I am looking for the expected result below. Taking the AVGSale on the right column, with the Internal ID_2 and Location ID matching to bring back the AVGSale on the Out of Stock visualization. If I was doing this on a calculated column would be a lookupvalue() eqauation, but I don't know how to do it on a measure.
Thank you,
Noel
Solved! Go to Solution.
You may check the following post.
https://community.powerbi.com/t5/Desktop/Average-of-category-for-timeseries/td-p/616215
At first it didn't work perfectly as my demand table could have a quantity of greater than 1 on a row, so the [amount] field would be a lot higher, and taking just the average of that one row could skew the results. I fixed it by doing the same suggested measure, but for [quantity] and dividing the two. Got me the correct results.
AVGSaleByLocation =
var itemLocation = SELECTEDVALUE('ns InventorySnapshot'[LocationId])
Return CALCULATE(AVERAGEX('Demand', 'Demand'[Amount]),
filter (ALL('Demand'[Internal ID_2]), 'Demand'[Internal ID_2]=itemLocation))
/
var itemLocationqty = SELECTEDVALUE('ns InventorySnapshot'[LocationId])
Return CALCULATE(AVERAGEX('Demand', 'Demand'[Quantity]),
filter (ALL('Demand'[Internal ID_2]), 'Demand'[Internal ID_2]=itemLocation))
@v-chuncz-msftIs there a more effiecent way of writing this formula that wouldn't envolve me calculating two different variables?
Thanks!
You may check the following post.
https://community.powerbi.com/t5/Desktop/Average-of-category-for-timeseries/td-p/616215
At first it didn't work perfectly as my demand table could have a quantity of greater than 1 on a row, so the [amount] field would be a lot higher, and taking just the average of that one row could skew the results. I fixed it by doing the same suggested measure, but for [quantity] and dividing the two. Got me the correct results.
AVGSaleByLocation =
var itemLocation = SELECTEDVALUE('ns InventorySnapshot'[LocationId])
Return CALCULATE(AVERAGEX('Demand', 'Demand'[Amount]),
filter (ALL('Demand'[Internal ID_2]), 'Demand'[Internal ID_2]=itemLocation))
/
var itemLocationqty = SELECTEDVALUE('ns InventorySnapshot'[LocationId])
Return CALCULATE(AVERAGEX('Demand', 'Demand'[Quantity]),
filter (ALL('Demand'[Internal ID_2]), 'Demand'[Internal ID_2]=itemLocation))
@v-chuncz-msftIs there a more effiecent way of writing this formula that wouldn't envolve me calculating two different variables?
Thanks!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 104 | |
| 82 | |
| 72 | |
| 46 | |
| 35 |