Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
prananellutla
Creator
Creator

Color expression based on rank(measure)by row

Hi Can we color the background cell in a table

I want to rank the measure in for each(Title col) using colormix gradient.

I am trying to work with this code here

Colormix(aggr(rank(sum([# Apps])),[Row dimension]),,RGB(67,89,56),RGB(x,y,z)

sample data.

  

titleJanFebMarAprMayJunJulAugSepOctNovDec
A387817974254286437502454704265516499
B1,3491,5018198061,1188157352,6691,5056096751,302
C19,71618,17717,08216,17019,12421,19720,41720,96321,11318,21916,83815,830

Something like attached.

Rank 1 in each row will be one color,rank 2 in each row will be second color etc.

  

thanks

1 Solution

Accepted Solutions
sunny_talwar

Why not try like this (if this is only for 1st three ranks)

If(HRank(Sum([# Apps])) = 1, Color1,

     If(HRank(Sum([# Apps])) = 2, Color2,

          If(HRank(Sum([# Apps])) = 3, Color3)))

View solution in original post

12 Replies
sunny_talwar

Why not try like this (if this is only for 1st three ranks)

If(HRank(Sum([# Apps])) = 1, Color1,

     If(HRank(Sum([# Apps])) = 2, Color2,

          If(HRank(Sum([# Apps])) = 3, Color3)))

prananellutla
Creator
Creator
Author

Thankyou Sunny- I have 12 months so i can define 12 ranks.What is difference between Hrank and Rank?

Can we use gradient coloring here instead of defined solid colors?

sunny_talwar

HRank is used for pivoted dimensions in a pivot table and Rank is used in Straight table or unpivoted dimensions. Also, read here:

HRank ‒ QlikView

prananellutla
Creator
Creator
Author

Sunny -thanks again - the code worked.

sunny_talwar

Super

prananellutla
Creator
Creator
Author

Sunny when I apply a date filters- i think the code is not working? i selected a date range and i see just one col colored.

If no date filter I see color on every cell.

this is my code

If(HRank(Sum([# Applications])) = 1, RGB(221,217,196),

     If(HRank(Sum([# Applications])) = 2, RGB(197,217,241),

          If(HRank(Sum([# Applications])) = 3, RGB(242,220,219),

          If(HRank(Sum([# Applications])) = 4, RGB(235,241,222),

          If(HRank(Sum([# Applications])) = 5, RGB(228,223,236),

          If(HRank(Sum([# Applications])) = 6, RGB(218,238,243),

          If(HRank(Sum([# Applications])) = 7, RGB(250,191,143),

          If(HRank(Sum([# Applications])) = 8, RGB(196,215,155),

          If(HRank(Sum([# Applications])) = 9, RGB(146,205,220),

          If(HRank(Sum([# Applications])) = 10, RGB(230,184,183),

          If(HRank(Sum([# Applications])) = 11, RGB(196,189,151),

          If(HRank(Sum([# Applications])) = 12, RGB(191,191,191)))))))))))))

img1.jpg

sunny_talwar

Try this

If(HRank(Sum({1}[# Applications])) = 1, RGB(221,217,196),

     If(HRank(Sum({1}[# Applications])) = 2, RGB(197,217,241),

          If(HRank(Sum({1}[# Applications])) = 3, RGB(242,220,219),

          If(HRank(Sum({1}[# Applications])) = 4, RGB(235,241,222),

          If(HRank(Sum({1}[# Applications])) = 5, RGB(228,223,236),

          If(HRank(Sum({1}[# Applications])) = 6, RGB(218,238,243),

          If(HRank(Sum({1}[# Applications])) = 7, RGB(250,191,143),

          If(HRank(Sum({1}[# Applications])) = 8, RGB(196,215,155),

          If(HRank(Sum({1}[# Applications])) = 9, RGB(146,205,220),

          If(HRank(Sum({1}[# Applications])) = 10, RGB(230,184,183),

          If(HRank(Sum({1}[# Applications])) = 11, RGB(196,189,151),

          If(HRank(Sum({1}[# Applications])) = 12, RGB(191,191,191)))))))))))))

vkish16161
Creator III
Creator III

This will only simplify the nested if's

Pick (

HRank(Sum([# Applications])) , RGB(221,217,196), RGB(197,217,241), ("IN THIS ORDER")

)

prananellutla
Creator
Creator
Author

Thanks Vishnu- this avoids the confusion on # of braces in nested if stmt.