Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Creator III
Creator III

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

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
Highlighted
Creator III
Creator III

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

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

Highlighted
Creator III
Creator III

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

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 ','

Highlighted
Creator III
Creator III

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

I think it is because of syntax error,

You need to check the brackets and comma.

Highlighted
Creator III
Creator III

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

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

Highlighted
Specialist II
Specialist II

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

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')

Highlighted
Specialist II
Specialist II

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

Or You can use set analysis as -

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

Highlighted
Creator III
Creator III

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

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

Highlighted
Specialist II
Specialist II

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

Did you try the set analysis provided above?

Highlighted
Creator III
Creator III

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

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'

))))

.