4 Replies Latest reply: Feb 11, 2016 4:51 AM by Rohan DSouza

# Barchart show last n items sorted by dimension instead of measure

[

ROOM,ROOM_VALUE

Room1,7

Room2,12

Room3,9

Room4,2

Room5,8

Room6,1

Room7,6

];

How can I limit the bar chart to show last five rooms (Room3 to Room7)?

I tried limitation but it is based on measure value instead of dimension

• ###### Re: Barchart show last n items sorted by dimension instead of measure

Create a RoomNumber field first:

Load *, Num#(Replace(ROOM,'Room')) as RoomNumber Inline

[

ROOM,ROOM_VALUE

Room1,7

Room2,12

Room3,9

Room4,2

Room5,8

Room6,1

Room7,6

];

Then change your chart expression to use that RoomNumber field. For example sum(ROOM_VALUE) becomes sum({<RoomNumber={'>\$(=Max(RoomNumber,-5))'}>} ROOM_VALUE)

• ###### Re: Barchart show last n items sorted by dimension instead of measure

Hi,

You can use the Autonumber() function

[

ROOM,ROOM_VALUE

Room1,7

Room2,12

Room3,9

Room4,2

Room5,8

Room6,1

Room7,6

];

And then in the expression of your bar chart, write the expression as

Sum({\$<Key={'>\$(=Max(Key)-5)'}>}ROOM_VALUE)

Regards,

Rohan

• ###### Re: Barchart show last n items sorted by dimension instead of measure

Thanks, but this only work if the dimension has specific format (i.e. ends with number), any solution to work on other dimension value?

• ###### Re: Barchart show last n items sorted by dimension instead of measure

Hi,

Even if your dimension contains all alphabets, it works fine. As far as the dimension values are different, it will work.

Try this load script and use the same expression defined above i.e. Sum({\$<Key={'>\$(=Max(Key)-5)'}>}ROOM_VALUE)

[

ROOM,ROOM_VALUE

RoomA,7

RoomB,12

RoomC,9

RoomD,2

RoomE,8

RoomF,1

RoomG,6

];

You will get the same result i.e. last 5 Rooms result will be displayed.

Regards,

Rohan