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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Error in calculated dimension

Hello,

I have a straight table with a calculated dimension that goes:

=Sum(If(year(Today())*100+Week(Today())-1 < YEARWEEK +4, DEMANDED_QTY))

or

=If(year(Today())*100+Week(Today())-1 < YEARWEEK +4, Sum(DEMANDED_QTY))

But I get "Error in calculated dimension" in both methods

If I use

=If(year(Today())*100+Week(Today())-1 < YEARWEEK +4, DEMANDED_QTY)

The dimension works but I get one row per YEARWEEK ( I think)

I want to get the total amount demanded for the last 4 weeks on one row.

Anyone that has any ideas of what I'm doing wrong?

I tried moving the function to expressions and then it worked so I guess my problem is solved.

But I still would like to know why I can not do this as a dimension...

br

Martin

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Martin,

In general, when you use aggregation in calculated dimension (sum in your case), you have to use aggr() function around it to tell what you're aggregating by. This explains the error. I cannot tell what excatly it should be in your case without knowing your data model and you want to see in the table.
I guess moving it to expression was the correct choice.

View solution in original post

1 Reply
Anonymous
Not applicable
Author

Martin,

In general, when you use aggregation in calculated dimension (sum in your case), you have to use aggr() function around it to tell what you're aggregating by. This explains the error. I cannot tell what excatly it should be in your case without knowing your data model and you want to see in the table.
I guess moving it to expression was the correct choice.