Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis within set analysis | Qlik Sense

I need to sum anything with a Jrnl_number which is largest than the maximum Jrnl_number for a particular LineRef (here: 'Balance Brought Forward')

LineRefJrnl_numberValue
A11100
B12200
C13300
'Balance Brought Forward'14350
'Balance Brought Forward'15400
E16450
F17600

In this example the output should be 450 + 600 = 1,050.

I have tried the below but it doesn't seem to work. My mental logic was that a set analysis within a set analysis might work (but I suspect that's not the case).

sum(

  {$<

        Jrnl_number = {">$(=max({$<LineRef = {'Balance Brought Forward'}>}(Jrnl_number)))"} >}

      (Value)

  )

1 Solution

Accepted Solutions
sunny_talwar

Works in Qlik Sense also

Capture.PNG

View solution in original post

7 Replies
sunny_talwar

Your expression seems to be working for me

Capture.PNG

sunny_talwar

Does the data have single quotes around Balance Brought Forward? If it does, then you can try this

=Sum({$<Jrnl_number = {">$(=max({$<LineRef = {'*Balance Brought Forward*'}>}Jrnl_number))"}>}Value)

sunny_talwar

Works in Qlik Sense also

Capture.PNG

Not applicable
Author

Thanks for the help. Turns out the syntax was correct, I just had an incorrect assumption about an additional column. I'll mark your answer as correct.

sunny_talwar

Additional column? What was that assumption you were making?

Not applicable
Author

Essentially I needed to restrict the data to a date (both in what was being summed up and in finding the maximum JnL number), so the revised logic became something like this.

sum(

{$<

[TRX Date]= {"<=$(=date(MakeDate(year(max(total([TRX Date])))-1,12,31),'DD/MM/YYYY HH:MM:SS'))>=$(=date(MakeDate(year(max(total([TRX Date])))-1,12,30),'DD/MM/YYYY HH:MM:SS'))"},

Jrnl_number = {">$(=max({$<LineRef = {'Balance Brought Forward'},[TRX Date]= {"<=$(=date(MakeDate(year(max(total([TRX Date])))-1,12,31),'DD/MM/YYYY HH:MM:SS'))>=$(=date(MakeDate(year(max(total([TRX Date])))-1,12,30),'DD/MM/YYYY HH:MM:SS'))"}>}(Jrnl_number)))"}


>}

(Value)

)

sunny_talwar

Got it... thanks for sharing this additional information