DAX - Return multiple column rows from a single column row based on criteria

monsoonnut

New Member
Joined
Jul 1, 2016
Messages
13
I am creating a stores report in Excel 2016 using PowerPivot
I have been asked to include measures relating to any stores that are within 10% of the size (m3) of a given store, i.e. return a list of stores that are within that size threshold.
I do not need to query against more than one store at a time.

I have a stores dim table with lots of data but the relevant columns are:
LOC_NOSIZE
24187
36207
75215
29219
15231
17257
64290
12331
88364
3367
27430

<tbody>
</tbody>

I have created measures for StoreSize, MaxSize and MinSize as comparators:
StoreSize= MAX(Stores[SIZE])
MaxSize= [StoreSize]+([ StoreSize]*0.1)
MinSize= [StoreSize]-([ StoreSize]*0.1)
By passing a single store to a pivot I need to return all other stores that are within 10% of its size.
I believe I need a duplicate copy of the stores table but after that I am stuck.
I have tried every iteration of calculate with differing filters I can think of but as I am returning multiple values there are always errors.
I am sure this is possible but cannot work out how!
Any ideas, comments, help would be appreciated.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
My guess is a second table that is not connected to the first table. You need to write a measure that will return a value if the store in the second table is within the threshold of the store selected in the first table. So the trick is to harvest the Max and min sizes in the initial filter context, then use that to create a measure to return a non blank value from the list in the second table. I would try this (not tested)

stores in threshold =calculate(table2[size],filter(table2,table2[size] <= [MaxSize] && table2[size] >= [MinSize] ))

put a slicer on table1[loc no] and select 1 store
put table2[loc no] on rows in a pivot and the measure above on values.

you can watch my presentation about evaluation contexts from the Microsoft Data Insights Summit here if you want to improve your knowledge and skills. My MDIS Presentations - Excelerator BI
 
Last edited:
Upvote 0
Thanks Matt, worked like a charm.

It is what I was trying to do but in my formula I was filtering the first table rather than the second!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top