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

Conditional Expression

Hi Friends

RISK_YEAR201120122013
Item N0SalesNosPaidSalesNosPaidSalesNosPaid
22---12,57811,400---
2365,7772138,982------
2463,554122,50063,554236,10063,554328,500
25------26,80516,200
26---62,255112,500---
4110,59614,800------
42----137,000-129,800
4355,10818,00051,108421,83351,108180,396

In my above pivot table I have all data in display. But I want to dis only records highlighted in red. in other words  all records where all columns have figures. Pls help me to solve this problem

Thanks

1 Solution

Accepted Solutions
MarcoWedel

Hi upali,

one possible solution could be:

QlikCommunity_Thread_112511_Pic1.JPG.jpg

QlikCommunity_Thread_112511_Pic2.JPG.jpg

QlikCommunity_Thread_112511_Pic3.JPG.jpg

SET minimum3 = if($1<$2 AND $1<$3, $1, if($2<$1 AND $2<$3, $2, $3));

tabData:

LOAD [Item N0],

     RISK_YEAR,

     Sales,

     Nos,

     Paid

FROM

[http://community.qlik.com/thread/112511]

(html, codepage is 1252, embedded labels, table is @2);

tabTemp:

LOAD

  [Item N0],

  $(minimum3(CountSales, CountNos, CountPaid)) as MinCount;

LOAD

  [Item N0],

  Sum(IsNum(Sales))*-1 as CountSales,

  Sum(IsNum(Nos))*-1 as CountNos,

  Sum(IsNum(Paid))*-1 as CountPaid

Resident tabData

Group By [Item N0];

Left Join (tabTemp)

LOAD

  Count(DISTINCT RISK_YEAR) as RiskYearCount

Resident tabData;

Left Join (tabData)

LOAD Distinct

  [Item N0],

  MinCount >= RiskYearCount as RecordComplete

Resident tabTemp;

DROP Table tabTemp;

This solution takes into account that not only the distinct number of RISK_YEARs per Item No decides whether the records for this Item No are complete or not. In your example there are rows with missing sales values which I also wanted to count for this check.

Hope this helps

regards

Marco

View solution in original post

5 Replies
whiteline
Master II
Master II

Hi.

There are different ways.

You can modify the data model to calculate the flag for each Item in script (one additional load with group by statement). Then use it in your expressions:

Sum({<[Item all years]={1}>} Sales)

Or you can use set analysis in your expressions to omit the unnecessary Items. 

Depending on your data model, the set expression to keep these items could be:

Sales: Sum({<[Item N0]={'=Count(distinct RISK_YEAR)=3'}>} Sales)

Or you can use the same logic as above using calculated dimension instead of Item N0. It's useful when you don't want modify each expression but can be less performance effective.

upaliwije
Creator II
Creator II
Author

Thanks Whiteline

"You can modify the data model to calculate the flag for each Item in script (one additional load with group by statement)."


I do not understand above part can you write the sample script for me please

whiteline
Master II
Master II

LOAD

     [Item N0],

     Count(distinct RISK_YEAR)=3 as [Item all years]

Resident DataTable

Group by  [Item N0];

MarcoWedel

Table for script tests:

Item N0RISK_YEARSalesNosPaid
222011---
23201165,7772138,982
24201163,554122,500
252011---
262011---
41201110,59614,800
422011---
43201155,10818,000
22201212,57811,400
232012---
24201263,554236,100
252012---
26201262,255112,500
412012---
422012-137,000
43201251,108421,833
222013---
232013---
24201363,554328,500
25201326,80516,200
262013---
412013---
422013-129,800
43201351,108180,396
MarcoWedel

Hi upali,

one possible solution could be:

QlikCommunity_Thread_112511_Pic1.JPG.jpg

QlikCommunity_Thread_112511_Pic2.JPG.jpg

QlikCommunity_Thread_112511_Pic3.JPG.jpg

SET minimum3 = if($1<$2 AND $1<$3, $1, if($2<$1 AND $2<$3, $2, $3));

tabData:

LOAD [Item N0],

     RISK_YEAR,

     Sales,

     Nos,

     Paid

FROM

[http://community.qlik.com/thread/112511]

(html, codepage is 1252, embedded labels, table is @2);

tabTemp:

LOAD

  [Item N0],

  $(minimum3(CountSales, CountNos, CountPaid)) as MinCount;

LOAD

  [Item N0],

  Sum(IsNum(Sales))*-1 as CountSales,

  Sum(IsNum(Nos))*-1 as CountNos,

  Sum(IsNum(Paid))*-1 as CountPaid

Resident tabData

Group By [Item N0];

Left Join (tabTemp)

LOAD

  Count(DISTINCT RISK_YEAR) as RiskYearCount

Resident tabData;

Left Join (tabData)

LOAD Distinct

  [Item N0],

  MinCount >= RiskYearCount as RecordComplete

Resident tabTemp;

DROP Table tabTemp;

This solution takes into account that not only the distinct number of RISK_YEARs per Item No decides whether the records for this Item No are complete or not. In your example there are rows with missing sales values which I also wanted to count for this check.

Hope this helps

regards

Marco