3 Replies Latest reply on Jul 13, 2016 8:23 AM by Felix Lutterbeck

# Create new measure dependent on dimension coming from parameter

Hi all,

I am trying to create a new measure from an existing measure that is conditional on two dimensions which I would like to select via parameters.

Here is an illustration of what I would like to do:

My data has prices for different fruits on different dates. The measure here is price and dimensions are fruitname and date. I have also created two parameters which allow me to select two different type of fruit.

I would now like to create a new measure which calculated the price difference of the two fruits I have selected via the parameters. The result of which should look like the yellow-shaded fields below.

• ###### 1. Re: Create new measure dependent on dimension coming from parameter

I doesn't make sense.

Which price and date will appear for these ones? Difference first less second?

It's easy to build but hard to mix with fruitname.

Follow an example in separated sheets.

• ###### 2. Re: Create new measure dependent on dimension coming from parameter

Hi Luciano

thanks for your reply. You are right the question was not 100% clear.  See below for better explanation.

The date should be the common date of both fruitnames (date is a dimension, like fruitname). The new price is fruitname 1 minus fruitname 2.

• ###### 3. Re: Create new measure dependent on dimension coming from parameter

Hi Felix,

What you want to do is creating two measures along the lines of:

if parameter_fruit1 = apple

then sum(if fruit = apple then price else null end)

if parameter_fruit1 = banana

then sum(if fruit = banana then price else null end)

end

Create the second one bases on parameter_fruit2.

Create a third one where you basically just subtract the previously created calculated fields from each other.

Drag the date dimension onto the rows shelve and drag out the third calculated field (diff) and that should do the trick.

Best,

Fabian

InterWorks Europe