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: 
richnorris
Creator II
Creator II

Error in calculation?

Hi, can anyone see what I'm doing wrong here? I have a calculated dimension of:

=if(Week < Week(Max([Trade Date]) ), Week)

Which should show all weeks other than the week of the maximum trade date, right? This isn't what I'm trying to achieve overall, so I'm not looking for alternatives, just why this peice of code isn't working?

5 Replies
MK_QSL
MVP
MVP

Instead of Calculated Dimension

Use

Dimension = Week

Expression

Something Like

SUM({<Week = {'$(=Week(Max([Trade Date])))'}>}Sales)

richnorris
Creator II
Creator II
Author

So you're saying its impossible to fix that code to work?

MK_QSL
MVP
MVP

not like that...

this is alternate suggestion.

if you upload you sample file or apps, we can see what exactly wrong with your calculated dimension.

swuehl
MVP
MVP

I think you would need to use advanced aggregation (aggr() function) in your calculated dimension if you want to use an aggregation function.

But it's probably easier if you define

=max([Trade Date])

in a variable vMaxTradeDate, then use this in the calculated dimension:

=if(Week < Week(vMaxTradeDate), Week)

(and check if [Trade Date] is a date with a numeric representation, so max() will return a value)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think you just need to add the TOTAL qualifier.

=if(Week < Week(Max(TOTAL [Trade Date]) ), Week)


-Rob