Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
shekhar_analyti
Specialist
Specialist

How to color code non aggregated tabular data based on increase of measure value ?

Hi All ,

How to color code non aggregated tabular data based on increase of measure value ?

Table

     

MeasureValueYearCountryRegionItemComponentBrand
Rank82010IndiaNorthAnalgesicBTBCipla
Rank82011JapanCentralSedativeAcetylamylinPfizer
Rank72009JapanCentralSedativeAcetylamylinPfizer
Rank72009KoreaCoastalSedativeAcetylamylinPfizer
Rank72009JapanBaySedativeAcetylamylinPfizer
Rank62009IndiaNorthAnalgesicBTBPfizer
Hold52010JapanCentralSedativeAcetylamylinLupin
Hold52010KoreaCoastalSedativeAcetylamylinLupin
Hold52010JapanBaySedativeAcetylamylinLupin
Hold42010IndiaNorthAnalgesicBTBLupin
Hold42011KoreaCoastalSedativeAcetylamylinLupin
Rejection_Index42013JapanBaySedativeAcetylamylinPfizer
Rejection_Index32011JapanCentralSedativeAcetylamylinPfizer
Rejection_Index32012JapanCentralSedativeAcetylamylinPfizer
Rejection_Index22011JapanCentralSedativeAcetylamylinPfizer
Rejection_Index22011KoreaCoastalSedativeAcetylamylinPfizer
Rejection_Index22011JapanBaySedativeAcetylamylinPfizer

OutPut

1 Solution

Accepted Solutions
sunny_talwar

May be this

Legend:

LOAD AutoNumber(Measure&Country&Region&Item&Component&Brand) as Key,

Measure,

    Value,

    Year,

    Country,

    Region,

    Item,

    Component,

    Brand

FROM

[Colour on Aggr Data.xlsx]

(ooxml, embedded labels, table is Table);


FinalTable:

LOAD *,

If(Key = Previous(Key), If(Value > Previous(Value), 'Positive', If(Value < Previous(Value), 'Negative'))) as Trend

Resident Legend

Order By Key, Year;


DROP Table Legend;

Capture.PNG

View solution in original post

10 Replies
shekhar_analyti
Specialist
Specialist
Author

I have attached sample data with expected output and logic

shekhar_analyti
Specialist
Specialist
Author

shekhar_analyti
Specialist
Specialist
Author

stalwar1‌ ... Anything wrong Sir , with my data

sunny_talwar

Sir?? ... Whatever happened to Sunny Bhai

Nothing wrong with your data... I just didn't open the Excel file until you mentioned that in your post

I have attached sample data with expected output and logic
shekhar_analyti
Specialist
Specialist
Author

Accha .. i got it . I thought that by mistake i have uploaded wrong data , possibly a blank sheet .

Again ... needed your help Sunny Bhai .

Actually i had to show data with

1) Colour coding in Table (which is already there in excel)

2) List Box based selection :  If user select field value as Positive then aap show show only product those whose mesaure values are increasing and if selection is Negative then it should show measure values of product which got decreased over period of time .

Thanks & Regards

Shekar

sunny_talwar

May be this

Legend:

LOAD AutoNumber(Measure&Country&Region&Item&Component&Brand) as Key,

Measure,

    Value,

    Year,

    Country,

    Region,

    Item,

    Component,

    Brand

FROM

[Colour on Aggr Data.xlsx]

(ooxml, embedded labels, table is Table);


FinalTable:

LOAD *,

If(Key = Previous(Key), If(Value > Previous(Value), 'Positive', If(Value < Previous(Value), 'Negative'))) as Trend

Resident Legend

Order By Key, Year;


DROP Table Legend;

Capture.PNG

shekhar_analyti
Specialist
Specialist
Author

Thank You Bhai ...

I have just one question , that cant there be an alternative to above solution .

My only concern is that the Key you have created is from multiple field , and what if real time data is huge and full of unique values . Wont this key creation degrade the performance ?

I am sure this question might be very silly for a Legend   .

sunny_talwar

I have not done a lot of testing around AutoNumber, but I have found it to be slightly slower with large amount of data.... other alternative is this....

Legend:

LOAD Measure,

     Value,

     Year,

     Country,

     Region,

     Item,

     Component,

     Brand

FROM

[Colour on Aggr Data.xlsx]

(ooxml, embedded labels, table is Table);


FinalTable:

LOAD *,

If(Measure = Previous(Measure) and Country = Previous(Country) and Region = Previous(Region) and

Item = Previous(Item) and Component = Previous(Component) and Brand = Previous(Brand),

If(Value > Previous(Value), 'Positive',

If(Value < Previous(Value), 'Negative'))) as Trend

Resident Legend

Order By Measure, Country, Region, Item, Component, Brand, Year;


DROP Table Legend;

But any which way you would have to Order By all your fields which form your key and use them in the If statement....

shekhar_analyti
Specialist
Specialist
Author

Sunny Bhai , I observed that for one Scenario , Trend Setting is not working .

If you see Rejection Index is coming negative for one scenario for year 2011 , but instead of that value negative should have populated for year 2012 ...
Actually year 2011 have two entry , in such scenarios that record with max value of  given measure should be used for comparison .

I have saved that in qvw for easy reference .

Note : I have made slight change it data .

Thanks & Regards

Shekar