Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
jumiprado
Creator
Creator

Assign one value

   Hey guys!

I have a problem with two tables.

I have one like this

Key_fieldIDPeriodValue
X1-Mar 2018X1mar 20181000
X2-Mar 2018X2mar 20181500
X3-Mar 2018X3mar 20182000
X4-Mar 2018X4mar 2018100
X5-Mar 2018X5mar 2018500

And this other table

Key_field
IDPeriodCategory
X1-Mar 2018X1mar 2018Categ1
X2-Mar 2018X2Mar 2018Categ1
X2-Mar 2018X2Mar 2018Categ2
X2-Apr 2018X2Apr 2018Categ2
X3-Mar 2018X3Mar 2018Categ5
X4- Mar 2018X4Mar 2018Categ1
X5- Mar 2018X5Mar 2018Categ 2

and i need to join or applymap the Category for the same key_field (ID+Period) but when i have two values for the same Key_field this duplicate the values.

I need the following result table, where the value should be the same for the next period

Key_fieldIDPeriodValueCategory
X1-Mar 2018X1mar 20181000Categ1
X2-Mar 2018X2mar 20181500Categ2
X3-Mar 2018X3mar 20182000Categ5
X4-Mar 2018X4mar 2018100Categ1
X5-Mar 2018X5mar 2018500Categ2

Thanks

1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:

LOAD * INLINE [

    Key_field, ID, Period, Value

    X1-Mar 2018, X1, Mar 2018, 1000

    X2-Mar 2018, X2, Mar 2018, 1500

    X3-Mar 2018, X3, Mar 2018, 2000

    X4-Mar 2018, X4, Mar 2018, 100

    X5-Mar 2018, X5, Mar 2018, 500

];


Left Join (Table)

LOAD Key_field,

ID,

Period,

MaxString(Category) as Category

Group By Key_field, ID, Period;

LOAD * INLINE [

    Key_field, ID, Period, Category

    X1-Mar 2018, X1, Mar 2018, Categ1

    X2-Mar 2018, X2, Mar 2018, Categ1

    X2-Mar 2018, X2, Mar 2018, Categ2

    X2-Apr 2018, X2, Apr 2018, Categ2

    X3-Mar 2018, X3, Mar 2018, Categ5

    X4-Mar 2018, X4, Mar 2018, Categ1

    X5-Mar 2018, X5, Mar 2018, Categ2

];

View solution in original post

4 Replies
neelamsaroha157
Specialist II
Specialist II

Check this.

sunny_talwar

Try this

Table:

LOAD * INLINE [

    Key_field, ID, Period, Value

    X1-Mar 2018, X1, Mar 2018, 1000

    X2-Mar 2018, X2, Mar 2018, 1500

    X3-Mar 2018, X3, Mar 2018, 2000

    X4-Mar 2018, X4, Mar 2018, 100

    X5-Mar 2018, X5, Mar 2018, 500

];


Left Join (Table)

LOAD Key_field,

ID,

Period,

MaxString(Category) as Category

Group By Key_field, ID, Period;

LOAD * INLINE [

    Key_field, ID, Period, Category

    X1-Mar 2018, X1, Mar 2018, Categ1

    X2-Mar 2018, X2, Mar 2018, Categ1

    X2-Mar 2018, X2, Mar 2018, Categ2

    X2-Apr 2018, X2, Apr 2018, Categ2

    X3-Mar 2018, X3, Mar 2018, Categ5

    X4-Mar 2018, X4, Mar 2018, Categ1

    X5-Mar 2018, X5, Mar 2018, Categ2

];

jumiprado
Creator
Creator
Author

Thanks a lot!

jumiprado
Creator
Creator
Author

Thanks a lot!