Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
DavidŠtorek
Creator III
Creator III

Calculations based on synthetic dimension

Hi experts,

could you help me a little bit with following task?

I have to create 3 values (Energy cost, Penalty, Reserved capacity) two of them should be calculated based on user defined variables values (Penalty and Reserved capacity) so it must be done on frontend.

My question is what am I doing wrong, that calculation for Penalty does not work with synthetic dimension (expression as itself should be correct, based on that in other objects it works).

Maybe it is some stupis typo, but I am not able to get it work.

Capture.PNG

Your help is very appreciated.

For details see atached app.

1 Solution

Accepted Solutions
DavidŠtorek
Creator III
Creator III
Author

Hi all,

I solved the problem. Using synthetic dimensioun would require to adjust data model because of field ConsumptionPeak (which contains also null values).

To create bar chart with current data model it requires to use dummy dimension and three measures. The result is as required.

Capture.PNG

View solution in original post

7 Replies
avinashelite

Could you share the expression/how your calculating the dimension ? currently I don't have access for Qliksense ...if you share the expression we could help

DavidŠtorek
Creator III
Creator III
Author

Hi,

dimesion:

ValueList('Energy cost','Reserved capacity cost','Penalty')

measure:

If(ValueList('Energy cost','Reserved capacity cost','Penalty')='Energy cost',Sum(EnergyConsumption)*$(vCost),

If(ValueList('Energy cost','Reserved capacity cost','Penalty')='Penalty',Sum(If((aggr(ConsumptionPeak,[Year - Month])/0.25)>(vMonthCapacity+vYearCapacity),(aggr(ConsumptionPeak,[Year - Month])/0.25)-(vMonthCapacity+vYearCapacity),0))*vPenalty,

    If(ValueList('Energy cost','Reserved capacity cost','Penalty')='Reserved capacity cost',$(vMonthCapacity)*$(PriceOfMonthCapacity)+$(vYearCapacity)*$(vPriceOfYearCapacity))))

DavidŠtorek
Creator III
Creator III
Author

avinashelite‌ any inputs?

jonathandienst
Partner - Champion III
Partner - Champion III

Is the other place where the expression works inside a chart or table with dimensions? Perhaps you have a field value aggregate that is defined in this context, but does not work in a global context.

Test the expression in a text box. If it works there, it should work in the ValueList expression.

Its hard to debug the expression when it contains embedded variables.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
DavidŠtorek
Creator III
Creator III
Author

Hi, thank you for your reply.

Yes it should work but it does not. I works in both text field and KPI object. It shows something different than 0 if I use this expression in combination with some dimension.

Only where it does not work and I realy want it to is in this chart. It seems to be defined in global context.

Even if I change variables to numbers it is not getting better. (btw. variables are just numbers)

Any other ideas

jonathandienst
Partner - Champion III
Partner - Champion III

>>It shows something different than 0 if I use this expression in combination with some dimension.

Do you mean 'some selection'? Does the chart version not behave in the same way? As you have observed, the ValueList() dimension does not create a local context like a field dimension, so the expression is evaluated in the same context as the KPI object. I do not see why they would be different.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
DavidŠtorek
Creator III
Creator III
Author

Hi all,

I solved the problem. Using synthetic dimensioun would require to adjust data model because of field ConsumptionPeak (which contains also null values).

To create bar chart with current data model it requires to use dummy dimension and three measures. The result is as required.

Capture.PNG