Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I would like to rank the following table where the highest sale is ranked 1. then I ill store the table into qvd with a new field Ranking.
Store | Sales |
A | 3000 |
B | 2900 |
C | 756 |
D | 1645 |
E | 3680 |
F | 985 |
Thanks You.
Hi Didier,
Try this,
Data:
LOAD * INLINE [
Store, Sales
A, 3000
B, 2900
C, 756
D, 1645
E, 3680
F, 985
G, 985
];
Sales:
LOAD Store,
Sum(Sales) as OverAllSales
Resident Data Group By Store;
NoConcatenate
Rank:
LOAD *,
If(Isnull(Peek('Store')), 1, If(OverAllSales < Peek('OverAllSales'), Peek('Rank')+1, Peek('Rank'))) As Rank
Resident Sales
Order By OverAllSales desc;
Drop Table Sales, Data;
Store Rank into Rank.qvd (qvd);
Note: Script Updated
Hi
If you want front end
Dimension:-Store
Expression:-Rank(Sales)
TAB:
LOAD * INLINE [
Store, Sales
A, 3000
B, 2900
C, 756
D, 1645
E, 3680
F, 985
];
TAB1:
LOAD *, RowNo() as Rank
Resident TAB
order by Sales asc;
Store TAB1 into Rank.qvd(qvd);
Drop Table TAB;
For front end,
Add calculated Dimension: Store&Sales
Expression: Store, Sale and Rank(Sum(Sales))
make Store&Sales dimension invisible (Presentation Tab --> Hide Column)
Hi,May be help full
Try this
T1:
load * Inline [
Store, Sales
A, 3000
B, 2900
C, 756
D, 1645
E, 3680
F, 985
];
NoConcatenate
T2:
load *,
RowNo() as rank,
Resident T1 order by Sales desc;
DROP table T1;
Store T2 into ABC.qvd;
Hi Didier,
Try this,
Data:
LOAD * INLINE [
Store, Sales
A, 3000
B, 2900
C, 756
D, 1645
E, 3680
F, 985
G, 985
];
Sales:
LOAD Store,
Sum(Sales) as OverAllSales
Resident Data Group By Store;
NoConcatenate
Rank:
LOAD *,
If(Isnull(Peek('Store')), 1, If(OverAllSales < Peek('OverAllSales'), Peek('Rank')+1, Peek('Rank'))) As Rank
Resident Sales
Order By OverAllSales desc;
Drop Table Sales, Data;
Store Rank into Rank.qvd (qvd);
Note: Script Updated
Hi Bro,
After " F" i am adding "G,985" but Rank is not showing properly why ?
Regards,
Mahesh.
Hi mahesh,
Have you tried my code?
It works adding this.
Regards!
Hi Manuel Capella,
This Question was not posted by me. but After " F" i am adding "G,985" Rank is showing same to F&G.
Regards,
Mahesh
I know, but I think that it was interesting for you, because you was testing Tamil's answer.
Regards!!