8 Replies Latest reply: Aug 11, 2017 6:50 AM by Sofia Anveden

# If statement combined with set analysis

Hi everyone!

Im new to qlik sense and having problems with combining set analysis with an if statement. I am making a line chart and only want the last twelve months to be shown, but I also want a filter on a dimension. Its when Im adding the if statement that it stops working.

CustomerGroup=Numeric dimension

Indicator=Sum(NBCustomer)

This part works seperatly:

Kind regards,

Sofia

• ###### Re: If statement combined with set analysis

please tell us which dimensions and measures you are using in line chart.

• ###### Re: If statement combined with set analysis

Hello!

CustomerGroup=Numeric dimension

Indicator=Sum(NBCustomer)

Date=date dimension

• ###### Re: If statement combined with set analysis

why you need to use IF ?

• ###### Re: If statement combined with set analysis

I probably dont! If you have a better way I would very much appreciate it!

Kind regards,

Sofia

• ###### Re: If statement combined with set analysis

you can use set analysis also for CustomerGroup like below:

Sum({\$<Month=, Year=, Date={">=\$(=MonthStart(AddMonths(Max(Date),-12)))<\$(=MonthEnd(Max(Date)))"}, CustomerGroup = {"1"} >} [NbCustomer])

this will only filter CustomerGroup  = 1 regardless which CustomerGroup you selected, else you can use CustomerGroup *= {"1"} to take care also of CustomerGroup selections.

• ###### Re: If statement combined with set analysis

• ###### Re: If statement combined with set analysis

Thank you everyone! Now it works.

Kind regards,

Sofia