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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
tomf122
Contributor III
Contributor III

Aggrgating If statement within a pivot table

I am doing an if statement for a value field within in pivot table. I have 3 demensions they are PU, RR_constraint and material_no with PU being the top level, then RR_constraint and then material_no. For my expression my if statement is working perfectly when looking at the bottom level of material_no but when i try and look at it from a RR_constraint level it is not rolling up correctly. How can this be fixed. The if statement should be done at a material level and then values added up from there.I have tried aggregating it but not having any luck with it. expression is:

 

if( Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) = 0 or Sum({<OTDM_Type={"Finish_Actual"}, countable={1}>} QTY) = 0, if( Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) > Sum({$<OTDM_Type={"Finish_Plan"}>} Qty_Finish) + Sum({$<OTDM_Type={"Finish_Actual"}, K_status={"Manually_Created"}>} QTY), Sum({$<OTDM_Type={"Finish_Plan"}>} QTY), Sum({$<OTDM_Type={"Finish_Plan"}>} Qty_Finish) + Sum({$<OTDM_Type={"Finish_Actual"}, K_status={"Manually_Created"}>} QTY) ), if( Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) >= Sum({$<OTDM_Type={"Finish_Plan"}>} Qty_Finish) + Sum({$<OTDM_Type={"Finish_Actual"}, K_status={"Manually_Created"}>} QTY), fabs(Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) - Sum({<OTDM_Type={"Finish_Actual"}, countable={1}>} QTY)), if( Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) < Sum({$<OTDM_Type={"Finish_Plan"}>} Qty_Finish) + Sum({$<OTDM_Type={"Finish_Actual"}, K_status={"Manually_Created"}>} QTY) and Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) > Sum({<OTDM_Type={"Finish_Actual"}, countable={1}>} QTY), (Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) - Sum({<OTDM_Type={"Finish_Actual"}, countable={1}>} QTY)) + FABS((Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) - Sum({$<OTDM_Type={"Finish_Plan"}>} Qty_Finish) + Sum({$<OTDM_Type={"Finish_Actual"}, K_status={"Manually_Created"}>} QTY))), FAbs( Sum({$<OTDM_Type={"Finish_Plan"}>} QTY) - Sum({$<OTDM_Type={"Finish_Plan"}>} Qty_Finish) + Sum({$<OTDM_Type={"Finish_Actual"}, K_status={"Manually_Created"}>} QTY) ) ) ) )

Labels (2)
1 Reply
henrikalmen
Specialist II
Specialist II

I think maybe you need to simplify your expression for this example so that it is more readable, and you should probably include some more information in your question - perhaps some images of what it looks like and more explanation of what is wrong in that image and how you want it to be. Perhaps even example of some raw/straight data that is feeding the pivot table. It is very difficult to try to help you based on the information you have given so far.