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

Compare non-numeric data in two periods

Hi

I have a table with companies and their ratings (Moody's ratings) and have already assigned a ranking value for each of the rating.  How do I compare two periods of the ratings and provide a Status column that says "Upgrade", "Downgrade", or "No Change"?

See below table (ratings are no base on real life ratings!):

MonthCompanyMoodyRating Rank
OctAppleA15
OctIBMAa12
OctGenetechAa34
OctSamsungBaa18
SeptAppleAa34
SeptIBMAa23
SeptGenetechAaa1
SeptSamsungBaa18

and I wish to see something like this:

CompanyCurrent RatingCurrent Rating
  Rank
Prior RatingPrior Rating RankStatus
AppleA15Aa34Downgrade
IBMAa12Aa23Upgrade
GenetechAa34Aaa1Downgrade
SamsungBaa18Baa18No Change

thanks

Louise

1 Solution

Accepted Solutions
MarcoWedel

like this:

tabRatingRank:

LOAD Dual([Moody’s], RecNo()) as Moody

FROM [http://de.wikipedia.org/wiki/Moody%E2%80%99s](html, codepage is 1252, embedded labels, table is @2, filters(Remove(Row, Pos(Top, 2)),Remove(Row, Pos(Top, 25)),Remove(Row, Pos(Top, 24))));

mapRatingRank:

Mapping LOAD Text(Moody), Moody

Resident tabRatingRank;

tabCompanyRating:

LOAD Month(Date#(Left(Month,3),'MMM')) as Month, //Left(,3) because of typo in posted sample data

    Company,

    ApplyMap('mapRatingRank', Moody) as Moody

FROM [http://community.qlik.com/thread/141152] (html, codepage is 1252, embedded labels, table is @3);

hope this helps

regards

Marco

View solution in original post

7 Replies
Gysbert_Wassenaar

See attached qvw


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

... or in the script something like this

TempData :

load

  Month,

  [Month Num] ,

  Company,

  Moody,

  [Rating Rank],

  previous ( [Rating Rank] ) as [Prior Rating Rank]

Resident Temp

order by Company , [Month Num]

;

drop table Temp ;



left join ( TempData)

load

  *

;

load

  Company ,

  max ( [Month Num] ) as MaxMonth

resident TempData

group by Company

order by Company

;

Data :

NoConcatenate

load

  *

resident TempData

where MaxMonth = [Month Num]

;

drop table TempData ;

drop table Temp ;

left join ( TempData)

load

  *

;

load

  Company ,

  max ( [Month Num] ) as MaxMonth

resident TempData

group by Company

order by Company

;

Data :

NoConcatenate

load

  *

resident TempData

where MaxMonth = [Month Num]

;

drop table TempData ;

Not applicable
Author

I forgot to add in one more criteria, the "Current Month" will be selected by the user...so I dont want to hard code the month in the expression.  thanks.

Not applicable
Author

Hi Bill,

I am not very good at reading script, so I cant say that I undersatnd your solution.  Is it possible to ask you to make it into a qvw file.  also, like I have responded to Gysbert's posting, my user will be making the selection for the current month.  so here is a sample table with more months.

MonthCompanyMoodyRating Rank
NovAppleA15
NovIBMA26
NovGenetechA37
NovSamsungBaa310
OctAppleA15
OctIBMAa12
OctGenetechAa34
OctSamsungBaa18
SeptAppleAa34
SeptIBMAa23
SeptGenetechAaa1
SeptSamsungBaa18
AugAppleAaa1
AugIBMBaa29
AugGenetechBa111
AugSamsungCaa117

thanks a lot

Louise

MarcoWedel

Hi,

one solution could be:

QlikCommunity_Thread_141152_Pic1.JPG.jpg

Using a dual load of the rating with an underlying ranking value, i.e. sorting of the rating field will be correct without any additional sorting expression.

QlikCommunity_Thread_141152_Pic2.JPG.jpg

QlikCommunity_Thread_141152_Pic3.JPG.jpg

QlikCommunity_Thread_141152_Pic4.JPG.jpg

QlikCommunity_Thread_141152_Pic5.JPG.jpg

QlikCommunity_Thread_141152_Pic6.JPG.jpg

QlikCommunity_Thread_141152_Pic7.JPG.jpg

tabRatingRank:

LOAD Dual(Moody, MoodyRank) as Moody;

LOAD [Moody’s] as Moody,

    RecNo() as MoodyRank

FROM [http://de.wikipedia.org/wiki/Moody%E2%80%99s](html, codepage is 1252, embedded labels, table is @2, filters(Remove(Row, Pos(Top, 2)),Remove(Row, Pos(Top, 25)),Remove(Row, Pos(Top, 24))));

mapRatingRank:

Mapping LOAD Text(Moody), Moody

Resident tabRatingRank;

tabCompanyRating:

LOAD Month(Date#(Left(Month,3),'MMM')) as Month,

    Company,

    ApplyMap('mapRatingRank', Moody) as Moody

FROM [http://community.qlik.com/thread/141152] (html, codepage is 1252, embedded labels, table is @3);

Edit: tabRatingRank could be implemented without preceding load.

hope this helps

regards

Marco

MarcoWedel

like this:

tabRatingRank:

LOAD Dual([Moody’s], RecNo()) as Moody

FROM [http://de.wikipedia.org/wiki/Moody%E2%80%99s](html, codepage is 1252, embedded labels, table is @2, filters(Remove(Row, Pos(Top, 2)),Remove(Row, Pos(Top, 25)),Remove(Row, Pos(Top, 24))));

mapRatingRank:

Mapping LOAD Text(Moody), Moody

Resident tabRatingRank;

tabCompanyRating:

LOAD Month(Date#(Left(Month,3),'MMM')) as Month, //Left(,3) because of typo in posted sample data

    Company,

    ApplyMap('mapRatingRank', Moody) as Moody

FROM [http://community.qlik.com/thread/141152] (html, codepage is 1252, embedded labels, table is @3);

hope this helps

regards

Marco

Not applicable
Author

Hi Marco, your solution looks like it should work out for me.  I havent have the time to test it out yet (sorry for the delay).  I will definitely give it a try next week and let you know!  thanks

Louise