Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
bimartingo
Contributor III
Contributor III

What's wrong with this set expression?

SUM( { <FIELD_A = FIELD_B> } METRIC)

I want to Sum all values of METRIC where values of FIELD_A match the values of FIELD_B.

1 Solution

Accepted Solutions
erichshiino
Partner - Master
Partner - Master

Hi,

One alternative to Fernando`s solution is the p() function.

SUM( { <FIELD_A =p(FIELD_B)}> } METRIC)

But if you want to make a test row by row, I suggest you create a flag in script.

LOAD FIELD_A, FIELD_B,

IF( FIELD_A = FIELD_B, 1,0) AS FLAG_AB

...

Then, your set analysis would be

SUM( { <FLAG_AB = {1}}> } METRIC)

Hope this helps,

Erich

View solution in original post

4 Replies
fernando_tonial
Partner - Specialist
Partner - Specialist

is wrong because the fields FIELD_B has many different values.

you can try this:

SUM( { <FIELD_A = {$(=Concat(FIELD_B,',')}> } METRIC)

Best regards.

Tonial.

Don't Worry, be Qlik.
Not applicable

Hi,

  Did you checked is there is any values avilable in both the columns?

-Jai

perumal_41
Partner - Specialist II
Partner - Specialist II

Hi,

Create one Variable vFIELD= '=concat(Chr(39) &FIELD_B&Chr(39),',')'

SUM( { <FIELD_A = {'$(vFIELD)'}>}METRIC) .u try This method .

erichshiino
Partner - Master
Partner - Master

Hi,

One alternative to Fernando`s solution is the p() function.

SUM( { <FIELD_A =p(FIELD_B)}> } METRIC)

But if you want to make a test row by row, I suggest you create a flag in script.

LOAD FIELD_A, FIELD_B,

IF( FIELD_A = FIELD_B, 1,0) AS FLAG_AB

...

Then, your set analysis would be

SUM( { <FLAG_AB = {1}}> } METRIC)

Hope this helps,

Erich