Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jagdishbr
Contributor III
Contributor III

Need a help on the below

Hi,

I'm new to qlikview and need help on the below challenge is it possible to do this in LOAD Statement.

Source data in Excel

from the above table need to split Ename and search the department they belong to from the below table. if EName appears in Trade department we need to ignore the rest of the search and update the dept. in the above table as "Trade". if not, should check for an employee if he falls under the Analytics department if not sales.

S 1. If multiple employees belongs to Trade department we still update as Trade

S 2. If an employee belongs to Trade as well Analytics then still we update the records as Trade

S 3. If an employee appears as Analytics and sales we update the record as Analytics

Reference data in Excel

Priority list

department "Trade" supersedes priority 2  (Analytics)  and (3 Sales)

1 Solution

Accepted Solutions
jagdishbr
Contributor III
Contributor III
Author

Sunny,

Apologize for the above post. it's my bad, I have added all the fields. Please ignore.

It worked as expected. Thanks a lot for your help.

View solution in original post

9 Replies
sunny_talwar

Would you be able to provide the expected output for the data you provided once all the data is loaded

jagdishbr
Contributor III
Contributor III
Author

Sunny, it need to be update on the source data as below.

sunny_talwar

How did you get the 4th row in your table?

jagdishbr
Contributor III
Contributor III
Author

Just as an example I have added

sunny_talwar

Try like this

Table:

LOAD * INLINE [

    Ename, Dept

    Michle, Analytics

    Mini, Trade

    Alex, Sale

    Gibs, Analytics

    Iva, Sale

    Roshan, Sale

    Andy, Sale

    Sidebottom, Trade

    Paul, Sale

];


Left Join (Table)

LOAD * INLINE [

    Dept, Priority

    Trade, 1

    Analytics, 2

    Sale, 3

];


MappingTable:

Mapping

LOAD Ename,

Priority

Resident Table;


Fact:

LOAD *,

If(SubStringCount(MapSubString('MappingTable', EnameList), '1'), 'Trade',

If(SubStringCount(MapSubString('MappingTable', EnameList), '2'), 'Analytics', 'Sale')) as Dept;

LOAD * INLINE [

    Date, EnameList

    20/12/2017, "Michle, Mini, Alex"

    12/12/2017, "Gibs, Iva, Roshan"

    13/12/2017, "Andy, Paul, Sidebottom"

    20/12/2017, "Roshan, Andy, Alex"

];

jagdishbr
Contributor III
Contributor III
Author

Hi Sunny,

Thanks for your effort and the solution.

Observation:

output should not increase the number of rows and if you observe 2nd row of the qv output "michle" is not part of EnameList for second row

Output:

Input and output no of records should be the same

Input fields are date and Ename and the Output should be date, Ename and dept

jagdishbr
Contributor III
Contributor III
Author

Sunny,

Apologize for the above post. it's my bad, I have added all the fields. Please ignore.

It worked as expected. Thanks a lot for your help.

sunny_talwar

I guess you are seeing this because of these two tables

Capture.PNG

Do you not want them in the script after everything is done? If not, then you can drop it, because if you look at your Fact table, we only have 4 rows

Capture.PNG

New Script if the above two tables are not needed anymore

Table:

LOAD * INLINE [

    Ename, Dept

    Michle, Analytics

    Mini, Trade

    Alex, Sale

    Gibs, Analytics

    Iva, Sale

    Roshan, Sale

    Andy, Sale

    Sidebottom, Trade

    Paul, Sale

];


Left Join (Table)

LOAD * INLINE [

    Dept, Priority

    Trade, 1

    Analytics, 2

    Sale, 3

];


MappingTable:

Mapping

LOAD Ename,

Priority

Resident Table;


Fact:

LOAD *,

If(SubStringCount(MapSubString('MappingTable', EnameList), '1'), 'Trade',

If(SubStringCount(MapSubString('MappingTable', EnameList), '2'), 'Analytics', 'Sale')) as Dept;

LOAD * INLINE [

    Date, EnameList

    20/12/2017, "Michle, Mini, Alex"

    12/12/2017, "Gibs, Iva, Roshan"

    13/12/2017, "Andy, Paul, Sidebottom"

    20/12/2017, "Roshan, Andy, Alex"

];


DROP Table Table;

sunny_talwar

Hahahaha, no problem... but how is this correct response?

Capture.PNG