Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
gasparbenito
Contributor II
Contributor II

Condition in Set expression

Hi all,

Can someone help me with this?

I have an Excel file with a list of costs per line, according to the product (sale).

And in the script I have calculated that each of those lines, multiply that cost by the boxes (unit of sale) sold.

Right now, there is only one cost per reference (line), regardless of the year.

I want to add the year field, as the cost per product varies each year, and now applies the same cost, regardless of the selected year.

The current formula is:

ApplyMap ('Map_CosteCaja', Mid (% Key_Articulo, FindOneOf (% Key_Articulo, '123456789')), 0) * #Cajas as #CosteVentas

How can I add to this formula the option that if for example, if I select 2017 it uses a cost and if I select 2018 it uses a different cost?

For example: 

ReferenciaAñoCoste
10000120171,25
10000120181,35

Thanks in advance!

Gaspar

1 Solution

Accepted Solutions
rubenmarin

Hi Gaspar,

The 2nd parameter of applymap uis the value to search, add a concatenated key using Year, and also include year in the first field on the mapping table Map_CosteCaja.

ApplyMap ('Map_CosteCaja', YearField&'#'&Mid (% Key_Articulo, FindOneOf (% Key_Articulo, '123456789')), 0) * #Cajas as #CosteVentas

View solution in original post

2 Replies
rubenmarin

Hi Gaspar,

The 2nd parameter of applymap uis the value to search, add a concatenated key using Year, and also include year in the first field on the mapping table Map_CosteCaja.

ApplyMap ('Map_CosteCaja', YearField&'#'&Mid (% Key_Articulo, FindOneOf (% Key_Articulo, '123456789')), 0) * #Cajas as #CosteVentas

gasparbenito
Contributor II
Contributor II
Author

Hi Ruben,

It works, I found the field in the Fact table and I have joined it following your advice YearField & '#' &

Many thanks!