Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Ashley33
Contributor II
Contributor II

How to calculate fabs of a monthly difference and sum the end results by dimension = item name?

Hello Dears,

Grateful for your help to build a qliksense formula for a bar chart with Dimension = Item name / description

Please note that my raw excel data will contain only columns A to I but not the last columns J. 

I have included column J here in order to show the calculation which i need to implement in qliksense, that is first i need to calculate column G in qliksense for each row of item data. This i have already done and is working.

Column AColumn BColumn CColumn DColumn EColumn FColumn GColumn HColumn IColumn J
Country CodeCountryItem name / descriptionYearMonthPeriod idTotal Stock End Of Curr MonthTotal Stock Start Of Curr MonthTotal Qty ShippedAbs(G - H)
+
I
AUSAustraliaCable samsung N102020120200167000370010400
AUSAustraliaCable samsung N10202022020028200670043005800
AUSAustraliaCable samsung N102020320200312008200540012400
AUSAustraliaCable Apple A20202012020015300018007100
AUSAustraliaCable Apple A20202022020022400530033006200
AUSAustraliaCable Apple A20202032020033500240011002200
          
          
          
When user selects month = 3 in qliksense, display 2 item bars:Bar 1:0.468531469=SUM(I3+I4+I5)/SUM(J3+J4+J5)   
          
    Bar 2:0.722580645=SUM(G6+G7+G8)/SUM(J6+J7+J8)   

 

Users Requirement (upon dynamic selection of year and month):

In the filters when the user selects Year = 2020 and Month 2, the bar chart should display 2 bars with results cumulated for month 1 and 2 inclusive

In the filters when the user selects Year = 2020 and Month 3, the bar chart should display 2 bars with results cumulated for month 1 till month 3 inclusive.

That is when user selects month 3, there will be 2 bars displayed as follows:

Bar 1 for 'Cable samsung N10' calculated cumulatively for month 1 till 3 inclusive with result 0.46

Bar 2 for 'Cable Apple A20' calculated cumulatively for month 1 till 3 inclusive with result 0.72

(Note:The excel file is attached)

I have tried to implement the bar chart with Dimension = Item name / description and i would like you to check if the formula below is correct? Thanks for confrming if it is ok.

=
Aggr(sum({$<Month= {">=0"}, Month = {"<= $(=Max(Month))"} >} [Total Qty Shipped]), Year, Month, [Item name / description])
/
(
fabs(Aggr(sum({$<Month= {">=0"}, Month = {"<= $(=Max(Month))"} >} [Total Stock End Of Curr Month]) , Year, Month, [Item name / description])
-
Aggr(sum({$<Month= {">=0"}, Month = {"<= $(=Max(Month))"} >} [Total Stock Start Of Curr Month]), Year, Month, [Item name / description])
)
+
Aggr(sum({$<Month= {">=0"}, Month = {"<= $(=Max(Month))"} >} [Total Qty Shipped]), Year, Month, [Item name / description])
)

 

 

0 Replies