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

Symmetric difference to get changes between years

Hello, I'm looking to achieve the following:

I do have a table consisting of data entries like that:

State Institute Period Permission

State AInstitute APeriod 11
State AInstitute BPeriod 11
State AInstitute CPeriod 10
State AInstitute DPeriod 10
State AInstitute APeriod 20
State AInstitute BPeriod 21
State AInstitute CPeriod 21
State AInstitute DPeriod 20

 

(...)

My goal is to display the changes of Permission between certain periods in a map. So, if there is a change of a permission for an institute that I can color the certain state and display the corresponding institutes with a change.

I thought of using a symmetric difference operator in a  chart expression to first get a list of all institutes with a permission in Period 1 in a certain state:

State Institute Period Permission

State AInstitute APeriod 11
State AInstitute BPeriod 11

 

then second to get a list of all institutes with a permission in Period 2:

State Institute Period Permission

State AInstitute BPeriod 21
State AInstitute CPeriod 21

 

and after that using a XOR to get only the changed institutes:

State Institute Period Permission

State AInstitute APeriod 11
State AInstitute CPeriod 21

 

Now, I tried putting a formula together to display the changes in a map but this isn't working as aspected as this simply displays all the institutes with a permission disregarding the period or the XOR:

concat({<Permission={1}, Period={'Period 1'}> / <Permission={1}, Period={'Period 2'}>} distinct Institute, ', ')

Can anybody help me? Thank you!

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

Hi, 
I've created in the script a field that is called Dim with this expression :
 

[Table]:
load *,
     State & '_' & Institute  as Dim;
LOAD * INLINE 
[
State,Institute,Period,Permission
State A,Institute A,Period 1,1
State A,Institute B,Period 1,1
State A,Institute C,Period 1,0
State A,Institute D,Period 1,0
State A,Institute A,Period 2,0
State A,Institute B,Period 2,1
State A,Institute C,Period 2,1
State A,Institute D,Period 2,0
](delimiter is ',');

then I used this expression to get the desired results:

max({<Dim=P({<Permission={1}, Period={'Period 1'}>}Dim) /p({<Permission={1}, Period={'Period 2'}>}Dim)>}Permission)

see attached app

 

View solution in original post

2 Replies
lironbaram
Partner - Master III
Partner - Master III

Hi, 
I've created in the script a field that is called Dim with this expression :
 

[Table]:
load *,
     State & '_' & Institute  as Dim;
LOAD * INLINE 
[
State,Institute,Period,Permission
State A,Institute A,Period 1,1
State A,Institute B,Period 1,1
State A,Institute C,Period 1,0
State A,Institute D,Period 1,0
State A,Institute A,Period 2,0
State A,Institute B,Period 2,1
State A,Institute C,Period 2,1
State A,Institute D,Period 2,0
](delimiter is ',');

then I used this expression to get the desired results:

max({<Dim=P({<Permission={1}, Period={'Period 1'}>}Dim) /p({<Permission={1}, Period={'Period 2'}>}Dim)>}Permission)

see attached app

 

jsjohann
Contributor
Contributor
Author

Thanks a lot! This seems to be working like expected.