Skip to main content
Question

SUM IF Funktionality

  • May 13, 2020
  • 4 replies
  • 7 views

Dear All I am looking for a solution to calculate a KPI based on a condition I tried it with this statement but there is an error CASE WHEN EKBE.VGABE LIKE 2 THEN SUM(EKBE.WRBTR) ELSE 0 END)

4 replies

Forum|alt.badge.img+2
Hi Marco, you need to put the CASE WHEN inside the aggregation function: SUM ( CASE WHEN "EKBE"."VGABE" LIKE '2' THEN "EKBE"."WRBTR" ELSE NULL END ) Cheers David

  • Author
  • Level 3
  • October 13, 2020
Hello @d.becher David, thanks a lot and would would i work if i need a pull function? CASE WHEN EKBE.VGABE = 1 THEN SUM(PU_SUM(EKPO(EKBE.QTY, EKBE.VGABE,EKBE)) ELSE 0.0 END thank you

  • Author
  • Level 3
  • October 13, 2020
@ All Here is the formula that works. (PU_SUM (EKPO,( CASE WHEN EKBE.VGABE LIKE 1 THEN (EKBE.QTY) ELSE NULL END ))) how ever now when I create another function the value duplicate sometimes in the olap table. (EKPO.MENGE)-(PU_SUM (EKPO,( CASE WHEN EKBE.VGABE LIKE 1 THEN (EKBE.QTY) ELSE NULL END ))) Any idea? Thank you

Forum|alt.badge.img+2
Hi Marco, the result of your PU function is now based on the EKPO table. When you add another dimension with another table, you are introducing the join to that other table. For example, if you introduce the join to the Activity table, you will see the result of your PU function next to every Activity of the corresponding case, because multiple rows in your Activity table belong to the same case. For more information, you can check out the Join functionality page in our PQL Documentation. Cheers David