Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.

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

Showing results for

Showing results for

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

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

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?

1,139 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.

1,058 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

1,131 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)

1,089 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

1,084 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.

1,067 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.

1,059 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!

1,051 Views

Community Browser