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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Qliksense_77
Creator
Creator

Multiple check if exists

Hi,

@rubenmarin  helped me with a solution in this post:

https://community.qlik.com/t5/New-to-Qlik-Sense/calculated-measure-in-script/m-p/1811809#M185921

How do I add an extra check if exists to this solution?

Lets say that I add a second rule so that I have both of these rules for the calculated measure :

1. When id and dates are identical, and the names starts with "b*" and "c*", then  only sum rows where name starts with "c". 

2. When id and dates are identical, and the names starts with "a*" and "c*", then  only sum rows where name starts with "c". 

1 Reply
Qliksense_77
Creator
Creator
Author

Ok, I figure that I should do more check of Id-Date. But then what is the correct expression in load script. The red expression below gives correct number, but with a minus??


chkIdDate:
LOAD chkIdDate
Where Count=2;
LOAD chkIdDate,
count(distinct Name) as Count
group by chkIdDate;
LOAD Id &'_'&Date as chkIdDate,
Left(Name,1) as Name
FROM [lib://AttachedFiles/Qlik forum calculate measure in script (ny version).xlsx]
(ooxml, embedded labels, table is Ark1)

Where Left(Name,1)='b' or Left(Name,1)='c';

 

chkIdDate2:
LOAD chkIdDate2
Where Count=2;
LOAD chkIdDate2,
count(distinct Name) as Count
group by chkIdDate2;
LOAD Id &'_'&Date as chkIdDate2,
Left(Name,1) as Name
FROM [lib://AttachedFiles/Qlik forum calculate measure in script (ny version).xlsx]
(ooxml, embedded labels, table is Ark1)

Where Left(Name,1)='a' or Left(Name,1)='c';

 

LOAD
Id,
"Date",
Name,
Value,

Value-(If(Exists('chkIdDate' , Id&'_'&Date) and Left(Name,1)<>'c', 0, Value))-(If(Exists('chkIdDate2' , Id&'_'&Date) and Left(Name,1)<>'c', 0, Value)) as Value2

FROM ...