Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
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: 
trishita
Creator III
Creator III

How to add records of same type in a chart expression?

if (Match([SC_FUEL_TYPE],'DMA'), sum(num(FUEL_MASS_BEFORE_SOUNDING/ 1000, ' ####.###', '.', ',' )),

if (Match([SC_FUEL_TYPE],'DMB'), sum(num(FUEL_MASS_BEFORE_SOUNDING/ 1000, ' ####.###', '.', ',' )),

if (Match([SC_FUEL_TYPE],'RMK 500'), sum(num(FUEL_MASS_BEFORE_SOUNDING/ 1000, ' ####.###', '.', ',' )),

if (Match([SC_FUEL_TYPE],'RMG 500'), sum(num(FUEL_MASS_BEFORE_SOUNDING/ 1000, ' ####.###', '.', ',' )),'Unknown'))))

I used this code, but still its not working.Could anyone give a try?

I want to see the sum of individual fuel oil like sum of DMA, or RMD 80 or RMK 700

Should I use totat or aggregate function?

1 Solution

Accepted Solutions
sibin_jacob
Creator III
Creator III

Please try this one.

if (Match([Actual_Fuel_Type],'HSFO'), sum( total  {$<Actual_Fuel_Type={'HSFO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'LSDO'), sum( total  {$<Actual_Fuel_Type={'LSDO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'HSDO'), sum( total  {$<Actual_Fuel_Type={'HSDO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'ULSFO'),sum( total  {$<Actual_Fuel_Type={'ULSFO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),'Unknown'

))))

View solution in original post

11 Replies
sibin_jacob
Creator III
Creator III

Please try the below expression.

I have used TOTAL Keyword.

below expression included only for DMA, the same way you can add for the other values.



if (Match([SC_FUEL_TYPE],'DMA'), sum({<[SC_FUEL_TYPE]={'DMA'}>} Total FUEL_MASS_BEFORE_SOUNDING))

Thanks,

Sibin

trishita
Creator III
Creator III
Author

if (Match([Actual_Fuel_Type],'HSFO'), sum( total  {$<Actual_Fuel_Type={'HSFO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000)),

if (Match([Actual_Fuel_Type],'LSDO'), sum( total  {$<Actual_Fuel_Type={'LSDO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000)),

if (Match([Actual_Fuel_Type],'HSDO'), sum( total  {$<Actual_Fuel_Type={'HSDO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000)),

if (Match([Actual_Fuel_Type],'ULSFO'),sum( total  {$<Actual_Fuel_Type={'ULSFO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000)),'Unknown'))))

OR

if (Match([SC_FUEL_TYPE],'RMG 500'), sum( total  {$<SC_FUEL_TYPE={'RMD 500'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000)),

if (Match([SC_FUEL_TYPE],'DMA'), sum( total  {$<SC_FUEL_TYPE={'DMA'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000)),

if (Match([SC_FUEL_TYPE],'DMB'), sum( total  {$<SC_FUEL_TYPE={'DMB'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000)),'Unknown')))))

if (Match([SC_FUEL_TYPE],'RMD 80'),sum(total{$<SC_FUEL_TYPE={'RMD 80'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([SC_FUEL_TYPE],'RMK 700'),sum( total{$<SC_FUEL_TYPE={RMD 80}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([SC_FUEL_TYPE],'RMG 500'), sum( total{$<SC_FUEL_TYPE={DMA}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),'Unknown'))))))

When I am trying to do individually its working but when I am trying to use for multiple ifs this syntax is showing an error..

GARBAGE AFTER EXPRESSION ','

sibin_jacob
Creator III
Creator III

I think it is because of syntax error,

You need to check the brackets and comma.

sibin_jacob
Creator III
Creator III

Please try this one.

if (Match([Actual_Fuel_Type],'HSFO'), sum( total  {$<Actual_Fuel_Type={'HSFO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'LSDO'), sum( total  {$<Actual_Fuel_Type={'LSDO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'HSDO'), sum( total  {$<Actual_Fuel_Type={'HSDO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'ULSFO'),sum( total  {$<Actual_Fuel_Type={'ULSFO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),'Unknown'

))))

neelamsaroha157
Specialist II
Specialist II

Hi Trisha, Is there a reason that you are using all the Fuel types in different match statement?

If no, the  may be you can use -

if (Match([SC_FUEL_TYPE],'DMA', 'DMB', 'RMK 500', 'RMG 500'), sum(num(FUEL_MASS_BEFORE_SOUNDING/ 1000, ' ####.###', '.', ',' )),

,'Unknown')

neelamsaroha157
Specialist II
Specialist II

Or You can use set analysis as -

Sum({<[SC_FUEL_TYPE] = {'DMA', 'DMB', 'RMK 500', 'RMG 500'}>}FUEL_MASS_BEFORE_SOUNDING)/1000

trishita
Creator III
Creator III
Author

No , but i want summed up values for this respesctive fuel type...i am new to qlikview and dont know so much..I tried to write the conditional statement

Sum of all fuel type DMA ;

SUM OF ALL FUEL TYPE DMB

neelamsaroha157
Specialist II
Specialist II

Did you try the set analysis provided above?

trishita
Creator III
Creator III
Author

The syntax is working fine..Only Now the records are duplicated.How can I fetch distinct records...

if (Match([Actual_Fuel_Type],'HSFO'), sum( total  {$<Actual_Fuel_Type={'HSFO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'LSDO'), sum( total  {$<Actual_Fuel_Type={'LSDO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'HSDO'), sum( total  {$<Actual_Fuel_Type={'HSDO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),

if (Match([Actual_Fuel_Type],'ULSFO'),sum( total  {$<Actual_Fuel_Type={'ULSFO'}>}FUEL_MASS_BEFORE_SOUNDING/ 1000),'Unknown'

))))

.