Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Error in calculated dimension that works as expression.

I have an expression that works just fine, but when I use it as a calculated dimension, it doesn't.  The expression gives me a margin % and is pasted below.

if([Division Abbreviation]='EFD',

(sum({$ <  [Fiscal Year] = {$(=ONLY("Current Fiscal Year"))}

             >} FACT_SHIPMENTS_AMOUNT_TY)

             -

             sum({$ <  [Fiscal Year] = {$(=ONLY("Current Fiscal Year"))}

             >} FACT_SHIPMENTS_QUANTITY_TY*[Item Cost]*[Item Length]*[Item Width]))

             /

sum({$ <  [Fiscal Year] = {$(=ONLY("Current Fiscal Year"))}

             >} FACT_SHIPMENTS_QUANTITY_TY*[Item Cost]*[Item Length]*[Item Width]),

             (sum({$ <  [Fiscal Year] = {$(=ONLY("Current Fiscal Year"))}

             >} FACT_SHIPMENTS_AMOUNT_TY)

             -

             sum({$ <  [Fiscal Year] = {$(=ONLY("Current Fiscal Year"))}

              >} FACT_SHIPMENTS_QUANTITY_TY*[Item Cost]))

             /

sum({$ <  [Fiscal Year] = {$(=ONLY("Current Fiscal Year"))}

               >} FACT_SHIPMENTS_QUANTITY_TY*[Item Cost])

    )

Any suggestions?

2 Replies
SunilChauhan
Champion II
Champion II

use

aggr(expression,keyfield) in dimension

Sunil Chauhan
jonathandienst
Partner - Champion III
Partner - Champion III

Brandon

A calculated dimension needs to return an array of data using something like the aggr function.

But beware that calcuated dimensions can be big performance killers, especially if they are as complex as your expression appears to be. It is better to calculate the dimension values in the load script and use the results in a dimension, if possible. You may need to undestand how selections would affect the dimension and ensure that you keep anough detail to maintain the operation of the system.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein