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

Set analysis zero values if no selection is made

I'm trying to get a count of all publications, that a customer in the USA has access to, which are located in the customers state, base on a date range. If a customer is selected, then I get the results I need.  If a customer is not selected, then the result is zero.    Count({=$(=(vPivot_StartDate))<$(=date(vPivot_Date))"},[PUB USA or International]={USA},[CAM USA or International]={USA},[CAMS_State]={"=PUB_State=CAMS_State"}> } DISTINCT(pubid)) I would like to be able to see both a result for all USA customers that use in-state publications as well as the individual customer results as well.  Thanks, Jen

13 Replies
Anonymous
Not applicable
Author

Count({=$(=(vPivot_StartDate))<$(=date(vPivot_Date))"},[PUB USA or International]={USA},[CAM USA or International]={USA},[PUB_State]={"=PUB_State=CAMS_State"}> } DISTINCT(pubid)) I left out the beginning of the statement.

Not applicable
Author

It looks like your syntax may be off in your statement.  Do you have an example you could upload?

Anonymous
Not applicable
Author

This is the full expression:

count({<view_date={">=$(=(vPivot_StartDate))<$(=date(vPiovot_Date))"),[PUB USA or International] = {USA},[CAM USA or International]={USA}, [PUB_State]={"=PUB_State=CAMS_State"}>} Distinct(pubid))

Not applicable
Author

count({<view_date={">=$(=(vPivot_StartDate))","<$(=date(vPiovot_Date))"},[PUB USA or International] = {'USA'},[CAM USA or International] = {'USA'}, [PUB_State]={'PUB_State','CAMS_State'}>} Distinct pubid)

Give that a try...

Anonymous
Not applicable
Author

Thank you very much for your response, but that resulted in zeros even with a customer selected.  I'm thinking I'm missing a $ somewhere because if one customer is selected it works.  If I want to see the overall view of all customers the result is zero.

swuehl
MVP
MVP

Hi Jen,

I think your problem is

[PUB_State]={"=PUB_State=CAMS_State"}

if you select more than one customer, this (PUB_State=CAMS_State will be ambigouus, I think.

I don't have a solution right now, maybe an indirect set expression? Or try with a row based conditional expression instead using advanced aggregation?

Anonymous
Not applicable
Author

I think you're right.  Initial, I had this calculated with an IF statement, which worked, but caused memory issues. 

Thank you for taking the time to respond.

Not applicable
Author

Do you have a sample I could take a look at? 

Anonymous
Not applicable
Author

This is the IF statement that works, but causes the memory issue.

=Sum(If(view_date >= vPivot_StartDate,if(view_date<vPivot_Date,if([CAM USA or International]='USA', if(PUB_National_Package='No', if(CAMS_STATE=PUB_State, Usage))))))