Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Melissa2
Contributor II
Contributor II

Variable calculates nothing when I remove a certain field

Hi guys

I am hoping that any of you can assist.  I have search quite a few topics but just could get a solution.

I have a variable which i defined as follow:

if(AccrualType = 'REB', sum(If( [Calculation type]= 'Value', QtyInvoiced * PromotionPercentage, NetSalesValue * PromotionPercentage/100)))

The AccrualType field consist of 6 different types of which REB is one of them.  Calculation type can either be Value or Percentage.

I used a straight table to test all formulas before I start with KPI etc.

The problem I am facing is that the variable calculates perfectly if I add my PromotionPercentage in my table, but as soon as I remove it then everything greys out.

See screenshots below - 1st is where PromotionPercentage is not part of the table and 2nd one I added that field.

Melissa2_0-1667485404423.png

Melissa2_1-1667485616124.png

 

Could it be because i have multiple % connected to that code and if so, how can I resolve it.

Thanking in advance.

Labels (1)
1 Reply
rubenmarin
MVP
MVP

Hi, it looks like a model isse, there is no relation between an invoice line and a promotion percentage, so each row is assigned to each promotion percentage.

In your 2nd image the turnover is 5850, and that value is applied the 7%, 2%... do you really want the sum of this value by each percentage?

Maybe with: if(AccrualType = 'REB', sum(If( [Calculation type]= 'Value', QtyInvoiced, NetSalesValue/100))*sum(* PromotionPercentage))

Or: if(AccrualType = 'REB', sum(aggr(sum(If( [Calculation type]= 'Value', QtyInvoiced * PromotionPercentage, NetSalesValue * PromotionPercentage/100)),PromotionPercentage)