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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
NBOnecall
Helper V
Helper V

Lookupvalue for a Measure, based on Visuals?

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).

Measure Lookup.png

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.

 

Measure Lookup Expected.png

Thank you,

Noel

2 ACCEPTED SOLUTIONS
v-chuncz-msft
Community Support
Community Support

@NBOnecall ,

 

You may check the following post.

https://community.powerbi.com/t5/Desktop/Average-of-category-for-timeseries/td-p/616215

Community Support Team _ Sam Zha
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

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!

 

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@NBOnecall ,

 

You may check the following post.

https://community.powerbi.com/t5/Desktop/Average-of-category-for-timeseries/td-p/616215

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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