# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
Valued Contributor

## Could Set Analysis be applied to dimension?

Could Set Analysis be applied to dimension? If so, how to do it? Could you please give one example?

Or could Set Analysis be only applied to measure?

Thanks!

1 Solution

Accepted Solutions
Highlighted
MVP

## Re: Could Set Analysis be applied to dimension?

I am a little confused, is this the same issue as with the dimension and set analysis?

Maybe try

=Pick(1+Match(Only({1} Region),'west','east','south','north'),

cyan(),

red(),

green(),

blue(),

yellow()

)

13 Replies
Highlighted
MVP

## Re: Could Set Analysis be applied to dimension?

You can apply set analysis using Aggr() function. For instance you want to see items based on category = x, you can try this:

Aggr(Only({<Category = {'x'}>} Item), Item)

Highlighted
MVP

## Re: Could Set Analysis be applied to dimension?

You can do this if you use advanced aggregation to allow aggregation functions in the calculated dimension, though for simple filtering of dimensional values, it might be easier to write:

If(Category = 'x', Item)

But there are settings were it's useful to have the set analysis option also in a calculated dimension / field expression in a list box.

Highlighted
Valued Contributor

## Re: Could Set Analysis be applied to dimension?

Thanks so much for your help!

My question is like this. I have a table with 3 columns, state, region, and sale_value. I need to show the map with state. I also need to set the region of the map with different color. At the same time, I need use region as a filter.

I use state as my dimension, and I created map color with expression:

If ( Region= 'west', red(),

If ( Region = 'east', green(),

(

if ( Region = 'south', blue(),

if (Region = 'north', yellow(), cyan())

)

)

)

)

I also created a measure and use Set Analysis.

My problem is that I can not create map color (for region) and put it on top of the map.

the map color legend (for region) is not interactive.

Could you please give any suggestion?

Highlighted
MVP

## Re: Could Set Analysis be applied to dimension?

I am a little confused, is this the same issue as with the dimension and set analysis?

Maybe try

=Pick(1+Match(Only({1} Region),'west','east','south','north'),

cyan(),

red(),

green(),

blue(),

yellow()

)

Highlighted
Valued Contributor

## Re: Could Set Analysis be applied to dimension?

Swuehl, thanks so much for your help! It works.

# Legend for color from Qlik Sense expression

Legend for color from Qlik Sense expression

# How to put marks on top of Qlik Sense map?

How to put marks on top of Qlik Sense map?

By the way, how could I add you to my connection at Qlik community? Or is it possible for you to add me to your Qlik connection at Qlik community? I would like to learn from you. Thanks again!

Highlighted
Valued Contributor

## Re: Could Set Analysis be applied to dimension?

My table has two columns, myDate and myValue. I use the table to create a bar chart. I would like to use Set Analysis to show the default date range between the first day of current year and current date.

I use the following Set Analysis, but it does not work. Could you please give any suggestion? Thanks!

Sum( {\$ <  date(myDate)> makedate(year(today())) and date(myDate)< today() > } myValue)

Highlighted
MVP

## Re: Could Set Analysis be applied to dimension?

Try this, assuming myDate format of 'MM/DD/YYYY' or adapt the format accordingly:

Sum(

{\$ <  myDate = {">=\$(=Date(Yearstart(Today()),'MM/DD/YYYY'))<=\$(=Date(Today(),'MM/DD/YYYY'))"} >}

myValue)

only field names allowed left side of a field modifier's equal sign (no functions). See also

A Primer on Set Analysis

Why is it called Set Analysis?

Dates in Set Analysis

Valued Contributor

## Re: Could Set Analysis be applied to dimension?

Swuehl, thanks so much for your help! I have a better understanding of Set Analysis Syntax now.

Your suggestion works well to set a default date range (fist date of current year to current date), however I still have some problem and would like to ask for your help.

I also use myDate as a filter (there is a default date range, and also I need to select other date range except default date range, for example, myDate starts from 2014)., When the default date range works, while the filter with myDate does not work any more.

Could you please give any suggestion?

Highlighted
MVP

## Re: Could Set Analysis be applied to dimension?

That's because your selection in myDate will be overwritten by the set modifier on the same field.

You can modify the above expression to

Sum(

{\$ <  myDate *= {">=\$(=Date(Yearstart(Today()),'MM/DD/YYYY'))<=\$(=Date(Today(),'MM/DD/YYYY'))"} >}

myValue)

Note the intersection operator *

now the field modifier will create a set made of the intersection between the previous default range and user selections (still, if the user selects last year, this will render the expression to return zero).

Another option would be to use a conditional statement, like If() to check for user selections using GetSelectedCount( myDate):

=If(GetSelectedCount(myDate), Sum (myValue), Sum( {<....>} myValue) )