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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating GM%

Dear fellow experts,

I have a table like this which is loaded in the script

Field                         Location          YTD     Month     Budget

Turnover                    Japan               100     20               110

Gross margin             Japan                 40     10               50

Operating profit          Japan                 10     2                 20           

Turnover                    India                1000     500               1100

Gross margin             India                 600         200               750

Operating profit          India                    300     100               350

How can i calculate the GM% as taking Gross margin divided by turnover in the resulting straight table or pivot table that i cra

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Table:

LOAD * INLINE [

Field,                         Location,          YTD,     Month ,    Budget

Turnover,                    Japan,               100,     20 ,              110

Gross margin,             Japan   ,              40  ,   10    ,           50

Operating profit,          Japan  ,               10  ,   2     ,            20          

Turnover,                    India ,               1000 ,    500 ,              1100

Gross margin,             India    ,             600    ,     200 ,              750

Operating profit,          India   ,                 300 ,    100  ,             350

];

Dim:

LOAD Field Resident Table;

LOAD 'GM %' as Field autogenerate 1;

Then create a straight table with dimension Field and expression

= if(Field = 'GM %' ,

     num( Sum(TOTAL {<Field = {'Gross margin'}>} YTD) / Sum(TOTAL {<Field = {'Turnover'}>} YTD),'0.0%','.',','),

      sum( YTD)

)

View solution in original post

6 Replies
swuehl
MVP
MVP

Create a straight table with dimension Location, then as Expression for YTD GM%

=Sum({<Field = {'Gross margin'}>} YTD) / Sum({<Field = {'Turnover'}>} YTD)

Month and Budget GM% accordingly.

robert_mika
Master III
Master III

10-Jul-15 12-12-04 PM.jpg

Format as %

Not applicable
Author

Hi both,

However, what if i want the GM% to appear as an additional field. That means when i select my straight table in Qlikview , rather than choosing location as the dimension, i will like to choose Fields as the dimension and include an additonal line called GM%.

Possible to be done?

Not applicable
Author

So the output should be something like this..

Field                                   YTD    

Turnover                              1100                 

Gross margin                         640                  

GM %                                    58.2%

Operating profit                      310     

Month and Budget GM% accordingly.

swuehl
MVP
MVP

Table:

LOAD * INLINE [

Field,                         Location,          YTD,     Month ,    Budget

Turnover,                    Japan,               100,     20 ,              110

Gross margin,             Japan   ,              40  ,   10    ,           50

Operating profit,          Japan  ,               10  ,   2     ,            20          

Turnover,                    India ,               1000 ,    500 ,              1100

Gross margin,             India    ,             600    ,     200 ,              750

Operating profit,          India   ,                 300 ,    100  ,             350

];

Dim:

LOAD Field Resident Table;

LOAD 'GM %' as Field autogenerate 1;

Then create a straight table with dimension Field and expression

= if(Field = 'GM %' ,

     num( Sum(TOTAL {<Field = {'Gross margin'}>} YTD) / Sum(TOTAL {<Field = {'Turnover'}>} YTD),'0.0%','.',','),

      sum( YTD)

)

Not applicable
Author

Hi Swuehl,

Thanks, the above suggestion worked for me! Anyway, rather than loading a autogenerate field in the table, i just entered GM% in the spreadsheet itself and then load into the Qlikview.

After that i inputted the straight table and typed in the formula as suggested. However i did a small change at the end so that the Sum(YTD) return an integer

= if(Field = 'GM %' ,

     num( Sum(TOTAL {<Field = {'Gross margin'}>} YTD) / Sum(TOTAL {<Field = {'Turnover'}>} YTD),'0.0%','.',','),

      num(sum( YTD),#,###)

)