Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

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

- Qlik Community
- :
- Forums
- :
- Analytics
- :
- New to Qlik Sense
- :
- If statement help

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

mapratt82

Creator

2015-10-26
11:05 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

If statement help

I'm trying to create a new measure using the following if statement, however not working help please.

if {[Ext Transaction Code]="326"} then

Sum([LAS Principal])-Sum([Charged Off Amount]);

else

Sum([LAS Principal]);

end if

232 Views

1 Solution

Accepted Solutions

sunny_talwar

MVP

2015-10-26
11:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Try this may be:

**If(****[Ext Transaction Code] = 326, ****Sum([LAS Principal]) - Sum([Charged Off Amount]), ****Sum([LAS Principal]))**

4 Replies

sunny_talwar

MVP

2015-10-26
11:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Try this may be:

**If(****[Ext Transaction Code] = 326, ****Sum([LAS Principal]) - Sum([Charged Off Amount]), ****Sum([LAS Principal]))**

rubenmarin

MVP

2015-10-26
11:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hi Mark, there are two kind of 'if', you're using the syntasx that controls wich section of the script runs, meanwhile the logic of your 'if' leads to a condition to check the loaded values, in this case the syntax is inside the load sentence:

LOAD YourFields,

If([Ext Transaction Code]=326, Sum([LAS Principal])-Sum([Charged Off Amount]), Sum([LAS Principal])) as LAS

//If(Condition, thenSentences, elseSentences) as NameOfResultingField

Btw, if you're using a Sum() inside the load you'll need to use the 'group by' clause.

mapratt82

Creator

2015-10-26
12:25 PM

Author

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Can you explain what you mean and what is the "group cause", please? Thanks!

156 Views

rubenmarin

MVP

2015-10-26
12:33 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

If you have aggregation functions like Sum(), Avg()... some function that makes a calculation over different records you'll neded to set aggroup by by all other fields that aren't in an aggregation function:

LOAD YourFields,

If([Ext Transaction Code]=326, Sum([LAS Principal])-Sum([Charged Off Amount]), Sum([LAS Principal])) as LAS

Group by Yourfields, [Ext Transaction Code];

But maybe you only need to remove the sum():

LOAD YourFields,

If([Ext Transaction Code]=326, [LAS Principal]-[Charged Off Amount],[LAS Principal]) as LAS

...

156 Views