Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Filtering a column based on other columns through Expression

Hello Qlik Community,

I have a question about an expression I am trying to figure out to try and accomplish the following:

I have the data set below. My goal is to provide an expression so that if 'Date' and/or 'Code' differs for any one PatientID, then ONLY display those 'PatientIDs'.

PatientIDDateCode
57087/1/20161
57088/4/20161
12857/2/20162
12857/2/20163
21207/3/20163
84627/4/20164
84628/1/20168
30027/5/20165
10987/6/20166

So with the data set above:

1. PatientID# 5708 would be displayed since there are two different 'Date' records for the same PatientID.

2. PatientID# 1285 would be displayed since there are two different "Code' records for the same PatientID.

3. PatientID# 8462 WOULD NOT be displayed since even though it has 2 records, neither 'Date' nor 'Code' is repeated for that record.

As for the rest of the records, they should ideally not even show up on my straight table chart since there is nothing wrong with them (including 8642 since nothing is wrong with it).

Overall, if 'Date' and/or 'Code' differs for one PatientID, then I would like that PatientID to show up on my straight table chart. If 'Date' and 'Code' do not differ, then I do not want that record to appear on my chart.

I know this can be accomplished and have made some strides towards accomplishing this, using this expression: =if(aggr(NODISTINCT count(Date),PatientID,Code)>1,1,0). But this, however, still shows me the some records like 1098 in the chart above which is just a single record without anything wrong with it and the 8642 example where there is nothing wrong with the record according my condition, but it still shows up in my table.

Thanks in advance! This would be great help for me!

Best Regards,

Tej

   

10 Replies
antoniotiman
Master III
Master III

Hi Tej,

Try Calculated Dimension

=Aggr(DISTINCT If((MinString(Date) = MaxString(Date) and Count(Date) > 1) or (MinString(Code) = MaxString(Code) and Count(Code) > 1),PatientID),PatientID)

check "Suppres when value is Null"

This works within your Data sample, I'm not sure within Your Data

Regards,

Antonio

sunny_talwar

May be create a straight table like this:

Dimensions

PatientID

Date

Code

Expression:

=If(Count(TOTAL <Date> Date) > 1 or Count(TOTAL <Code> Code) > 1, 1)

Capture.PNG

Expression can be hidden from the presentation tab

Not applicable
Author

Hey Antonio,

Thanks for yur reply. I tried applying the calculated dimension who gave me to the exact data source that I provided in the example above, but I am not getting the results that you received when I entered it. I made sure I put the formula in the calculated dimension area and clicked the suppress when value is null option and nothing would show up on the table. Is it maybe because of what I am using for my dimensions?

Please let me know, if you can, why I am not receiving the same reults as you did in your reponse.

Thank you,

Tej

antoniotiman
Master III
Master III

See attachment

Not applicable
Author

Antonio,

Unfortunately, I am using a personal edition of Qlikview until next week so I am unable to open files that are not created by me.

Sorry for the inconvenience. if it is not too much to ask, could you walk me through the steps you did to get the table in the way you did? that woul dbe very helpful to me.

Thank you,

Tej

Not applicable
Author

Hey Sunny,

I will try it out that way and get back to you.

Thanks,

Tej

Not applicable
Author

Hey Sunny,

I was able to get my table to look like the yours in the example. Once question I have though is why the patient ID 2120 shows up in the data set when that Patient ID does not have any variation in 'Date' and/or 'Code' as mentioned above?

Please let me know at your earliest convenience.

Thank you,

Tej

sunny_talwar

Apologize, I mis-interpreted the requirement. Try this:

=If((Count(DISTINCT TOTAL <PatientID> Date) = 1 or Count(DISTINCT TOTAL <PatientID> Code) = 1) and Count(TOTAL <PatientID> PatientID) = 2, 1)

Capture.PNG

antoniotiman
Master III
Master III

Dimensions :

1. Calculated Dimension (as Patient ID)

2. Date

3. Code

Expression : Date