Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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!
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
136 | |
118 | |
101 | |
71 | |
61 |