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

How do I add wildmatch results together?

Good afternoon, I am trying to add these fields together to get a total output. Qlickview is not liking the code even though it makes sense to me. i'm trying to get the total value for the field <Amount>

if(wildmatch(Rate_Category, 'M*'),Amount) as Measured_Value,    

if(wildmatch(Rate_Category, 'A*'),Amount) as Assessed_Value,

if(wildmatch(Rate_Category, 'U*'),Amount) as Unmeasured_Value

  

sum(Measured_Value)+sum(Assessed_Value)+sum(Unmeasured_Value) as sum_total

1 Solution

Accepted Solutions
Not applicable
Author

try with

if(wildmatch(Rate_Category, 'M*'),Amount) as Measured_Value,   

if(wildmatch(Rate_Category, 'A*'),Amount) as Assessed_Value,

if(wildmatch(Rate_Category, 'U*'),Amount) as Unmeasured_Value,

if(wildmatch(Rate_Category, 'M*'),Amount)+  if(wildmatch(Rate_Category, 'A*'),Amount)+if(wildmatch(Rate_Category, 'U*'),Amount) as sum_total

View solution in original post

3 Replies
swuehl
MVP
MVP

You can't reference the renamed fields in the same Load statement, they are unknown to QV until the load finished.

You can use a preceding load though, to use these new field names:

LOAD *,

rangesum(Measured_Value,Assessed_Value,Unmeasured_Value) as sum_total;

LOAD

...

if(wildmatch(Rate_Category, 'M*'),Amount) as Measured_Value,   

if(wildmatch(Rate_Category, 'A*'),Amount) as Assessed_Value,

if(wildmatch(Rate_Category, 'U*'),Amount) as Unmeasured_Value,

...

from Table;

Not applicable
Author

try with

if(wildmatch(Rate_Category, 'M*'),Amount) as Measured_Value,   

if(wildmatch(Rate_Category, 'A*'),Amount) as Assessed_Value,

if(wildmatch(Rate_Category, 'U*'),Amount) as Unmeasured_Value,

if(wildmatch(Rate_Category, 'M*'),Amount)+  if(wildmatch(Rate_Category, 'A*'),Amount)+if(wildmatch(Rate_Category, 'U*'),Amount) as sum_total

Not applicable
Author

Thanks Juan, that hit the spot! Have a great weekend guys,thanks for the help!