Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Chart/Graph Dimension Sort/Order on x Axis

HI All (my first post on QView community forum)

I am having problems with the sorting of the dimensions on the x axis of a chart.

This is the code for a dimension i have which groups a field i have.

  Code.bmp

The graph appears like this. With the ages completely out of order.

Graph.bmp

1 Solution

Accepted Solutions
mikecrengland
Creator III
Creator III

You could use a 'dual' function in your calcualted dimension

=If (Driver_1_Age<=18, dual('<18',1),

     If (Driver_1_Age<23, dual('<23',2),

etc...

Then sort numerically.

View solution in original post

14 Replies
SunilChauhan
Champion II
Champion II

sort-> expression wildmatch( expression, 'value1','value2',.....)_. ascending

wildmatch (if(deriver<=18,'<18'.......),'<18','19-23','24-28',...........)

hope this helps

Sunil Chauhan
Not applicable
Author

HI

I couldn't get this to work. Could you type two full lines of the expression?

I think i'm getting a little confused.

Regards

James - MI GIB

Not applicable
Author

HI

I couldn't get this to work. Could you type two full lines of the expression?

I think i'm getting a little confused.

Regards

James - MI GIB

jagan
Luminary Alumni
Luminary Alumni

Hi,

Check attached file for solution.

Hope it helps you.

Regards,

Jagan.

johnw
Champion III
Champion III

In case it means anything to anyone, I do this sort of thing like Jagan suggests, by using dual() to assign a numeric value to the range.

Not applicable
Author

Apologies   

i have ages 16 - 95. Would i need to create a Load inline for every age?

I also have around 50 other data items. would i need to create a preceeding load to bring in these additional items ??

Thanks for your help

James

jagan
Luminary Alumni
Luminary Alumni

Hi,

Can you attach the sample file that you are working.

Regards,

Jagan.

Not applicable
Author

This is my current code. Where would I put the LOAD * INLINE for the Driver_1_Age field ? ?

*****************************

SET ThousandSep=',';

SET DecimalSep='.';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='£#,##0.00;-£#,##0.00';

SET TimeFormat='hh:mm:ss';

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

LOAD

Insurer_Policy_Number,

year(Inception_Date) AS InceptionYear,

Inception_Date,

Duration_months,

Event_Code,

Scheme,

Transaction_Date,

Transaction_Net_Premium,

Transaction_Commission,

Transaction_Risk_Days,

Expiry_Date,

policy_id,

first_inception,

end_date,

product,

current_policy_counter,

Policy_Counter,

policy_number,

pnumber,

suffix2,

rnl,

nbs,

gwp,

netpluscomm,

netpluscommann,

contract,

Cover_Chunk_No,

Policy_Postcode,

Cover_Type,

Class_of_Use,

NCD_Years,

Other_NCD,

Intro_Discount,

Prot_Discount,

VDR_Code,

Number_of_Drivers,

Number_of_Convictions,

Number_of_Previous_Claims,

Contract_Type,

Main_Driver,

Number_of_Vehicles,

Source_Code,

Subscheme,

Agency,

Vhls_in_Household,

Transaction_IPT,

Transaction_Screen_Rate,

Transaction_Exposure_Days,

Transaction_Net_Earned_Premium,

Transaction_Number_of_Claims,

Transaction_Claim_Payments,

Transaction_Claim_Recoveries,

Transaction_Claim_Reserves,

Payment_Type,

Eff_From_Date,

Eff_From_Time,

Chunk_End_Date,

Status,

Driver_1_Age,

Driver_1_Sex,

Driver_1_Mar_Status,

Driver_1_Occ,

Driver_1_Licence,

Driver_1_Exp,

Driver_1_UK_Res,

Driver_1_Advanced_Qualifications,

Driver_1_Access_Other_Vhl,

Driver_1_Rel_Prop,

Vhl_1_Vehicle_Area_Code,

Vhl_1_Vol_Excess,

Vhl_1_Agreed_Value,

Vhl_1_ABI_Veh_Code,

Vhl_1_Veh_Group,

Vhl_1_Age,

Vhl_1_Value,

Vhl_1_Modified,

Vhl_1_Annual_Mileage,

Vhl_1_Garaged,

Vhl_1_Owner_Code,

Vhl_1_Keeper_Code,

Vhl_1_LH_Drive,

Vhl_1_Months_Owned,

Vhl_1_Body_Type,

Vhl_1_Number_of_Seats,

Vhl_1_Security_Device_1,

Vhl_1_Security_Device_2,

Vhl_1_Security_Device_3,

Vhl_1_Make,

Vhl_1_Model,

Vhl_1_registration_number,

Vhl_1_Overnight_postcode_1,

Vhl_1_Overnight_postcode_2,

Vhl_1_Engine_Capacity,

Driver_2_Age,

Driver_2_Sex,

Driver_3_Age,

Driver_3_Sex,

Driver_4_Age,

Driver_4_Sex,

ao_youngest_driver,

so_youngest_driver,

database,

Total_Payments,

Total_Recoveries,

Total_Estimates,

Total_Anticipated_Recoveries,

Total_Claim_Count,

incurred,

XOL_recoveries,

XOL_recoveries_nonNU,

number_of_capped_claims,

capped_costs,

zero_flag,

claim_count,

currexp,

net_earned_premium,

gep,

exposure,

retro,

pcode_formatted,

d_sector,

district,

Area_code,

Vehicle,

policy_suffix,

Source_System,

DID,

Area,

Payment_Made

FROM

Not applicable
Author

This is my current code. Where would I put the LOAD * INLINE for the Driver_1_Age field ? ?

*****************************

SET ThousandSep=',';SET DecimalSep='.';SET MoneyThousandSep=',';SET MoneyDecimalSep='.';SET MoneyFormat='£#,##0.00;-£#,##0.00';SET TimeFormat='hh:mm:ss';SET DateFormat='DD/MM/YYYY';SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';
LOAD
      
Insurer_Policy_Number,
       
year(Inception_Date)                                                AS InceptionYear,
    
Inception_Date,
    
Duration_months,
    
Event_Code,
    
Scheme,
    
Transaction_Date,
    
Transaction_Net_Premium,
    
Transaction_Commission,
    
Transaction_Risk_Days,
    
Expiry_Date,
    
policy_id,
    
first_inception,
    
end_date,
    
product,
    
current_policy_counter,
    
Policy_Counter,
    
policy_number,
    
pnumber,
    
suffix2,
    
rnl,
    
nbs,
    
gwp,
    
netpluscomm,
    
netpluscommann,
    
contract,
    
Cover_Chunk_No,
    
Policy_Postcode,
    
Cover_Type,
    
Class_of_Use,
    
NCD_Years,
    
Other_NCD,
    
Intro_Discount,
    
Prot_Discount,
    
VDR_Code,
    
Number_of_Drivers,
    
Number_of_Convictions,
    
Number_of_Previous_Claims,
    
Contract_Type,
    
Main_Driver,
    
Number_of_Vehicles,
    
Source_Code,
    
Subscheme,
    
Agency,
    
Vhls_in_Household,
    
Transaction_IPT,
    
Transaction_Screen_Rate,
    
Transaction_Exposure_Days,
    
Transaction_Net_Earned_Premium,
    
Transaction_Number_of_Claims,
    
Transaction_Claim_Payments,
    
Transaction_Claim_Recoveries,
    
Transaction_Claim_Reserves,
    
Payment_Type,
    
Eff_From_Date,
    
Eff_From_Time,
    
Chunk_End_Date,
    
Status,
    
Driver_1_Age,
    
Driver_1_Sex,
    
Driver_1_Mar_Status,
    
Driver_1_Occ,
    
Driver_1_Licence,
    
Driver_1_Exp,
    
Driver_1_UK_Res,
    
Driver_1_Advanced_Qualifications,
    
Driver_1_Access_Other_Vhl,
    
Driver_1_Rel_Prop,
    
Vhl_1_Vehicle_Area_Code,
    
Vhl_1_Vol_Excess,
    
Vhl_1_Agreed_Value,
    
Vhl_1_ABI_Veh_Code,
    
Vhl_1_Veh_Group,
    
Vhl_1_Age,
    
Vhl_1_Value,
    
Vhl_1_Modified,
    
Vhl_1_Annual_Mileage,
    
Vhl_1_Garaged,
    
Vhl_1_Owner_Code,
    
Vhl_1_Keeper_Code,
    
Vhl_1_LH_Drive,
    
Vhl_1_Months_Owned,
    
Vhl_1_Body_Type,
    
Vhl_1_Number_of_Seats,
    
Vhl_1_Security_Device_1,
    
Vhl_1_Security_Device_2,
    
Vhl_1_Security_Device_3,
    
Vhl_1_Make,
    
Vhl_1_Model,
    
Vhl_1_registration_number,
    
Vhl_1_Overnight_postcode_1,
    
Vhl_1_Overnight_postcode_2,
    
Vhl_1_Engine_Capacity,
    
Driver_2_Age,
    
Driver_2_Sex,
    
Driver_3_Age,
    
Driver_3_Sex,
    
Driver_4_Age,
    
Driver_4_Sex,
    
ao_youngest_driver,
    
so_youngest_driver,
    
database,
    
Total_Payments,
    
Total_Recoveries,
    
Total_Estimates,
    
Total_Anticipated_Recoveries,
    
Total_Claim_Count,
    
incurred,
    
XOL_recoveries,
    
XOL_recoveries_nonNU,
    
number_of_capped_claims,
    
capped_costs,
    
zero_flag,
    
claim_count,
    
currexp,
    
net_earned_premium,
    
gep,
    
exposure,
    
retro,
    
pcode_formatted,
    
d_sector,
    
district,
    
Area_code,
    
Vehicle,
    
policy_suffix,
    
Source_System,
    
DID,
    
Area,
    
Payment_MadeFROM