Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
MatiasJR
Contributor
Contributor

Using function in set analysis

Hi guys,

I have a field (State) that appears in another one (City). It's something like:

State  City

NY    New York/NY

NY    Albany/NY

CA   Los Angeles/CA

The last 2 digits of the city are always the state, so i can retrieve it by using =right(GetFieldSelections(City),2)

I have a graph that show the sum of the accidents that occured in the selected State. However, if I only select a City in the filter pane, I want  the graph for the State to show all the accidents from the selected State (from all the cities in the same State as the selected city). I'm trying to filter the sum by doing something like 

sum({<State = {right(GetFieldSelections(City),2)} >}[Accidents])

but can't get the set analysis to work. Any ideas?

Labels (3)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

try below for your State chart

sum({<State = p(State), City=>}[Accidents])

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

5 Replies
QFabian
Specialist III
Specialist III

Hi @MatiasJR , check this

Element set functions

The element set can also be based on the set functions P() (possible values) and E() (excluded values).

For example, if you want to select countries where the product Cap has been sold, you can use:

<Country = P({1<Product={Cap}>} Country)>

Similarly, if you want to pick out the countries where the product Cap has not been sold, you can use:

<Country = E({1<Product={Cap}>} Country)>

 

https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/SetAnalys...

 

QFabian
vinieme12
Champion III
Champion III

try below for your State chart

sum({<State = p(State), City=>}[Accidents])

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
MatiasJR
Contributor
Contributor
Author

Hey Vini, one quick question

 

What does the 'City =' means? What you're setting it equal to?

And the comma is the same as the asterisk, meaning interseccion of the conditions?

like shoul this have the same output

sum({<State = p(State)> * <City = >}[Accidents])

 

vinieme12
Champion III
Champion III

When you want to ignore selections made in a particular field  you  would use 

fieldToIgnore=

This will ignore all selections in that field 

 

<State = p(State)> * <City = >this means 

One set where state is all possible states 

Intersection with 

One Set where city selection is ignored

Think of a Venn diagram when working with multiple sets

 

Read more on set analysis below

https://www.analyticsvidhya.com/blog/2014/01/set-analysis-qlikview/#:~:text=What%20is%20SET%20ANALYS....

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
MatiasJR
Contributor
Contributor
Author

Got it! Thaks for the help, it worked perfectly.