Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ciaran_mcgowan
Partner - Creator III
Partner - Creator III

Find Sales Rank that is stored in separate table

Hi,

I have a table that isn't linked to anything else that stores a Salesperson's Rank. There are a lot of values (A - Z) that start at €0 = Z, €100 = Y all the way up to €1,000,000 = A. Once the sum of their sales passes these numbers, that is the rank they will be awarded (e.g. €99 = Z and €100 = Y).

Is there a better way to do this that what I have in mind?

Sales_tmp:

LOAD SalesPersonID,

          Sum(Sales)     AS SalesTotal

Resident

Sales

GROUP BY SalesPersonID;

Rank:

LOAD Rank,

          SalesTarget

FROM Rank;

MatchRank:

IntervalMatch(SalesTotal)

LOAD DISTINCT

          Previous(SalesTarget) AS SalesTarget_MIN,

          SalesTarget

Resident Rank;

I'm not sure if I should try this approach or try something with variables.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

I often use an extra step after interval matching to clean up a little, although it is not strictly necessary.

Sales_tmp:

LOAD SalesPersonID,

          Sum(Sales)     AS SalesTotal

Resident

Sales

GROUP BY SalesPersonID;

Rank:

LOAD Rank,

          SalesTarget

FROM Rank;

MatchRank:

IntervalMatch(SalesTotal)

Left Join LOAD DISTINCT

          Previous(SalesTarget) AS SalesTarget_MIN,

          SalesTarget

Resident Rank;

Left Join LOAD DISTINCT

     SalesTarget,

     Rank

Resident Rank;


DROP Table Rank;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

3 Replies
Kushal_Chawda

what is the expected output? Can you draw output?

jonathandienst
Partner - Champion III
Partner - Champion III

The logic looks OK to me - I would also use interval matching to deal with this. What is your concern?

EDIT I would add a join to the interval matching load rather than a straight load. That creates an association between the tables on Sales Target:

MatchRank:

IntervalMatch(SalesTotal)

Left Join LOAD DISTINCT

          Previous(SalesTarget) AS SalesTarget_MIN,

          SalesTarget

Resident Rank;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

I often use an extra step after interval matching to clean up a little, although it is not strictly necessary.

Sales_tmp:

LOAD SalesPersonID,

          Sum(Sales)     AS SalesTotal

Resident

Sales

GROUP BY SalesPersonID;

Rank:

LOAD Rank,

          SalesTarget

FROM Rank;

MatchRank:

IntervalMatch(SalesTotal)

Left Join LOAD DISTINCT

          Previous(SalesTarget) AS SalesTarget_MIN,

          SalesTarget

Resident Rank;

Left Join LOAD DISTINCT

     SalesTarget,

     Rank

Resident Rank;


DROP Table Rank;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein