Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $400 before Dec 31st: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
Brip51
Creator
Creator

Logic with IF and Multiple conditions

Hi,

I am trying to create a dimension that is derived from 3 fields and i am having a difficult time.

There should end up being three values-

Rep

Mar

Partner

This is the SQL I use currently which works as expected -

  Select

      case when M =1 then 'Mar'

            when LeadSource = 'C' or LeadSource='P'

or M = 0

or Dbb

not in (,'Direct','Sales','Brought',') then 'Partner'

            else 'Rep' end                        

as  Source

Here is what I have now in my app, but I cant get this worked out ----

If(M  = '1', 'Mar',

If(M  = '0','Partner'

OR

If(Match(Dbb,'Partner') = 1 , 'Partner','Rep Created')))


This only returns 'Mar"

Any help pointing me in the right direction would be greatly appreciated.


Thanks

Brian


1 Solution

Accepted Solutions
sunny_talwar

May be this

If(M = 1, 'Mar',

     If(Match(LeadSource, 'C', 'P') or M = 0 or not Match(Dbb, 'Direct', 'Sales', 'Brought'), 'Partner', 'Rep'))

View solution in original post

6 Replies
sunny_talwar

May be this

If(M = 1, 'Mar',

     If(Match(LeadSource, 'C', 'P') or M = 0 or not Match(Dbb, 'Direct', 'Sales', 'Brought'), 'Partner', 'Rep'))

sasiparupudi1
Master III
Master III

=If(M  = 1, 'Mar',

If(LeadSource,='C' OR LeadSource='P' OR M=0  OR NOT Match(Dbb,'Direct','Sales,'Bright'),'Partner','Rep')

)

DKK
Contributor III
Contributor III

Hi Brian,

See if this works..

There may be better way to do this..but try this:

if( M=1, 'Mar',

if ( ( LeadSource='C' or LeadSource='P' or  M=0 )   or  ( Dbb <> 'Direct' and  Dbb <> 'Sales' and  Dbb <> 'Brought') ,'Partner','Rep')

)

Brip51
Creator
Creator
Author

Hi Sasidhar,

This looks like it works.

There is a comma after the first "Leadsource" that I dropped assuming that was a typo.

I will check this again to be sure and mark as correct.

Thank you.  I have not been able to try all the suggestions yet but thanks to all for the speedy input!!

sunny_talwar

Feel free to use any of the expressions, but just as a suggestion... it requires less typing and makes the code looks nicer using Match() or WildMatch() functions

Best,

Sunny

Brip51
Creator
Creator
Author

Thank you Sunny.  This worked great for me as well and is a better fit for my code.

I appreciate all the help here !