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.

Announcements

QlikWorld 2023, a live, in-person thrill ride. April 17 - 20, 2023, in Las Vegas! **REGISTER TODAY**

- Qlik Community
- :
- Forums
- :
- Analytics
- :
- New to Qlik Sense
- :
- Re: If (Field A > Field B ), Then Sum(Calculation

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

bramvdpoel

Contributor III

2020-03-30
08:33 AM

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

If (Field A > Field B ), Then Sum(Calculation

Hello!

Search the forum but could not find any awnsers to my question:

I'm trying to make a #kpi like this:

~~IF(Field A > Field B, Sum((Field C - Field D) * Field E))~~

Correction: IF((Field A > Field B, Sum((Field A - Field B)*Field C))

But i can't seem to get to right answer, can anybody help?

501 Views

1 Solution

Accepted Solutions

tresesco

MVP

2020-03-31
02:37 AM

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

If all three fields are numeric, your expression should work with a sum() outside 'if' in KPI object, i.e.

**Sum(** If (A > B, ((A - B) * C)) ** )**

If this is not working in KPI object, check if field C is being treated as text or not and correct that accordingly. Otherwise, try to share a sample app.

420 Views

8 Replies

Mauritz_SA

Partner - Specialist

2020-03-30
08:58 AM

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

Hi there

I'm guessing you have many values in Field A and Field B? If so I think you're going to do an aggregation on those fields to use it in a KPI object. For example IF(Sum(Field A) > Sum(Field B), Sum((Field C - Field D) * Field E)).

Hope this helps.

Regards,

Mauritz

493 Views

sebastiandperei

Specialist

2020-03-30
09:42 AM

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

Hi!

If the another answer doesn't works, you could try

sum (if([Field A]>[Field B], ([Field C]-[Field D])*[Field E]))

robert99

Specialist III

2020-03-30
09:43 AM

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

Have you tried

sum(IF(Field A > Field B,

(Field C - Field D) * Field E

))

bramvdpoel

Contributor III

2020-03-30
11:04 AM

Author

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

This doesn't work, Field A & Field B are numeric field (values range from 0 to 50)

451 Views

Mauritz_SA

Partner - Specialist

2020-03-30
11:42 AM

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

Hi @bramvdpoel

Can you perhaps paste a short extract of your data with the expected output?

Regards,

Mauritz

446 Views

bramvdpoel

Contributor III

2020-03-31
02:20 AM

Author

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

A | B | C |

5 | 3 | 10,54 |

10 | 6 | 14,47 |

2 | 1 | 25,64 |

3 | 2 | 12,31 |

2 | 2 | 8,64 |

6 | 8 | 4,89 |

2 | 3 | 1,58 |

2 | 1 | 33,47 |

1 | 1 | 89,17 |

I wrote my formula wrong in my post earlier, here is an example piece.

If (A > B, ((A minus B) * C))

And then i want a total sum of all rows where A is bigger then B in a KPI.

429 Views

tresesco

MVP

2020-03-31
02:37 AM

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

If all three fields are numeric, your expression should work with a sum() outside 'if' in KPI object, i.e.

**Sum(** If (A > B, ((A - B) * C)) ** )**

If this is not working in KPI object, check if field C is being treated as text or not and correct that accordingly. Otherwise, try to share a sample app.

421 Views

bramvdpoel

Contributor III

2020-03-31
03:11 AM

Author

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

Got the KPI working, thx a lot everbody for the quick respones!

413 Views