Dynamic referencing in measure

phillip c

New Member
Joined
May 9, 2014
Messages
2
Hi All,

I have the following 2 measures:
Customer Sales:=CALCULATE(SUMx('hourly',hourly[Total sales]),FILTER('hourly',hourly[Customer Code]=275))
Supplier Sales:=CALCULATE(SUMx('hourly',hourly[Total sales]),FILTER('hourly',hourly[Supplier Code]=275))
which work just fine.
What I'm trying to achieve is have the customer code be selected dynamically based on a slicer. The reason I'm not just using a slicer based on customer/supplier is because I would like to see data for a certain company as both a customer AND a supplier in the same table. A slicer for a customer would filter our instances where that company is a supplier and vice versa.
Any help would be much appreciated.

Thanks,

Phillip
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I think you will need to have the codes in a separate table that is not related. Let's call it CustomerCodes.

Define a new measure:
[SelectedCustomerCode] := MIN(CustomerCodes
Code:
)

(if multiple are selected, its just going to return the first one...)

Then where you have 275 in your measures above, just use [SelectedCustomerCode] instead.
 
Last edited by a moderator:
Upvote 0
Hi Scottsen,

Thanks a lot for your reply. I ended up using a solution similar to the one you proposed, but I actually had to add not 1, but 2 unrelated tables.
If anyone is interested in the solution (and the problem), I can post it.
 
Upvote 0

Forum statistics

Threads
1,226,693
Messages
6,192,463
Members
453,725
Latest member
cvsdatreas

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