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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
William_Wistam
Contributor III
Contributor III

Unusual Expression Parsing with // (Comment) and Line Breaks in Qlik Sense SaaS - Possible Bug?

Hello Qlik Community,

I've encountered a very peculiar behavior with an expression in Qlik Sense SaaS that seems to defy standard parsing rules and might indicate a bug. I'm hoping to get some insight, confirmation, or a potential explanation for this.

The Goal:

I'm trying to calculate the sum of Revenue for a specific Period defined by a variable vMaxPeriod, using the TOTAL qualifier to get a grand total (disregarding chart dimensions).

The Working Expression (Surprisingly):

My expression only works when structured exactly like this, including the // (comment) characters and specific line breaks:

Code snippet
 
Sum({$<Period={$(vMaxPeriod)}>} //
    TOTAL [GL_Hub]
    Revenue)

Key Observations for the Working Expression:

  1. The // (comment characters) are present on the line immediately after the closing curly brace of the set analysis (}).
  2. TOTAL [GL_Hub] and Revenue) are on separate lines, following the line with the // comment.

The Problem: Expressions That Don't Work (and why they should according to documentation):

If I remove the // comment, or if I consolidate TOTAL [GL_Hub] Revenue onto a single line after the set analysis, the expression breaks and returns an error.

  1. Removing // (should work if // were just a comment):

    Code snippet
     
    Sum({$<Period={$(vMaxPeriod)}>}
        TOTAL [GL_Hub]
        Revenue)
    • Result: Does not work. This suggests the // is serving a functional purpose beyond just being a comment.
  2. Consolidating TOTAL and Field on one line (standard recommended syntax):

    Code snippet
     
    Sum({$<Period={$(vMaxPeriod)}>} TOTAL [GL_Hub] Revenue)
    • Result: Does not work. This is particularly confusing, as this syntax (Sum({SetAnalysis} TOTAL Field)) is generally the recommended way to get a grand total with set analysis in Qlik Sense.

My Environment:

  • Qlik Sense SaaS (Cloud)

My Question to the Community:

  • Has anyone else experienced this kind of behavior where a // comment seems to be functionally required for an expression to parse correctly?
  • Is there a documented reason for // to act as a "soft line break" or continuation marker in this specific scenario?
  • Is this a known bug in Qlik Sense SaaS, or am I missing a fundamental parsing rule specific to my environment?

I've verified that $(vMaxPeriod) resolves correctly to a valid period value and that [GL_Hub] Revenue is the correct field reference. The issue consistently lies with the presence/absence of // and the specific line breaks.

Any insights or similar experiences would be greatly appreciated!

Thank you,

Will

 

Labels (1)
  • SaaS

1 Solution

Accepted Solutions
rubenmarin

Hi, your 'GOOD' expression returns the same value with these expressions:

Sum({$<Period={$(vMaxPeriod)}>} //
    TOTAL SomethingThatIsAnError
	Revenue)
Sum({$<Period={$(vMaxPeriod)}>} TOTAL Revenue)

Also I don't understand your GOOD expression, it only shows the data for 202506 (1,165,164) in all the periods, It's really that what you want to show? What' are you trying to calcute by GL_Hub?

View solution in original post

10 Replies
rubenmarin

Hi, maybe it has something to do with he syntax after TOTAL, I'm not really sure what [GL_hub]. Is that a master item?

Usually after total there is only the field that has the measure, but in this case is GL_Hub and Revenue.

If Gl_Hub is a field to break the TOTAL, it should be between < and >, like: Sum({$<Period={$(vMaxPeriod)}>} TOTAL <GL_Hub> Revenue)

I don't have any clue about the //

vkramBI4Qlik
Contributor III
Contributor III

Hi @William_Wistam ,

Did you try using the dimension '<' and '>' like follows and also using the TOTAL dimension before the Set Analysis ? 

Sum( TOTAL <[GL_Hub]> {$<Period={$(vMaxPeriod)}>} Revenue)

Thanks

Vikram 

marcus_sommer

Beside the already mentioned total-syntax it's not recommended to include any comments within the expressions because they are a potential source of error - especially if they are nested in any way.

William_Wistam
Contributor III
Contributor III
Author

Hi Rubenmarin, apologies for the late reply due to some personal circumstances. Thank you for your reply and help.

I've attached a QlikSense file with simplified data to help prove the issue—please see the screenshot.
 
Example 1 shows the original expression with "//" and line breaks, which you can verify in the file.
Example 2 follows your suggestion with "<>" around GL_Hub, but it’s not working.
Example 3 uses Vikram's suggestion of moving TOTAL to the front, which also doesn’t work.
 
I’ve tried various combinations, but only Example 1 works, though it seems unusual. I’m using TOTAL because I need to show the user-defined revenue period regardless of the period, with the goal of calculating the delta for each period compared to the user-defined revenue period.

 

William_Wistam_1-1752095114178.png

Will

William_Wistam
Contributor III
Contributor III
Author

Hi Vikram, apologies for the late reply after 3 weeks due to some personal circumstances. Thank you for your help. Please refer to the message, examples, and attached QlikSense file I sent to Ruben for details on the issue and my attempts, including your suggested expression which didn’t work. I’m using TOTAL to show the user-defined revenue period regardless of the selected period, aiming to calculate the delta for each period compared to the user-defined revenue period.
 
Best,
Will
William_Wistam
Contributor III
Contributor III
Author

Hi Marcus, apologies for the late reply. Thank you for your help. Please refer to the message and file I sent to Ruben. I understand not to use comments "//", but removing them breaks the expression—it stops working.
 
Best,
Will
marcus_sommer

I don't want to exclude any parsing-bug but it seems quite unlikely to me because if nearly all common expressions wouldn't be working ...

... and if we look on the "not working" expression we see a result which seems to be quite correct. Therefore I assume that you are expecting a different result - probably by mistaken the functionality between an adjustment to the selection state per set analysis and adjusting the consideration of the object-dimensionalities by specifying a TOTAL statement.

A TOTAL ignores all relations to the dimensions of the current object - by extending it with something like <Field1, Field2> it ignores further all object-dimensions unless the extra listed ones. It's always performed against the available data-set which is specified by the set selections and/or the set adjustments within a set analysis - respectively the evaluation of the data-set comes always first.

In conclusion: the first expression is wrong and showed wrong results - IMO it should return always a syntax-error and not ignoring the set analysis by applying an empty comment. Maybe the direct line-break after the // "confused" the parser ... (you may play a bit with real comments like: // comment XYZ or /* abc */ to see if anything is changing - whereby like above mentioned it's not recommended to use comments within expressions - especially in regard to the efficiency of development-efforts and performance that if you would need ones that the data-model isn't suitable enough to support simple expressions).

rubenmarin

Hi, your 'GOOD' expression returns the same value with these expressions:

Sum({$<Period={$(vMaxPeriod)}>} //
    TOTAL SomethingThatIsAnError
	Revenue)
Sum({$<Period={$(vMaxPeriod)}>} TOTAL Revenue)

Also I don't understand your GOOD expression, it only shows the data for 202506 (1,165,164) in all the periods, It's really that what you want to show? What' are you trying to calcute by GL_Hub?

William_Wistam
Contributor III
Contributor III
Author

@rubenmarin Thanks for the solution! Appreciate your help. This works for me!