Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
farru_scorpio
Contributor III
Contributor III

Repeating times of a value in a table

Dear Experts,

I have a table where same amounts are being repeated n number of times what I want is to identify those number of repeats and put a marker like below:

// I have

DateCB            CBNumber           Amount
01-May-2021 BR00\21050009 320.00
01-May-2021 BR00\21050005 460.00
01-May-2021 BR00\21050007 460.00
01-May-2021 BR00\21050003 460.00
01-May-2021 BR00\21050033 320.00
01-May-2021 BR00\21050006 310.00
01-May-2021 BR00\21050004 2,225.00
01-May-2021 BR51\21050009 460.00

// I want

Repeats Amount_Marker
1               320-1
1               460-1
2               460-2
3               460-3
2              320-2
1              310-1
1              2225-1
4              460-4

 

Thank you in advance

Farrukh

1 Solution

Accepted Solutions
MayilVahanan

HI

Try like below

T1:
LOAD * INLINE [
DateCB,CBNumber ,Amount
01-May-2021 ,BR00\21050009, 320.00
01-May-2021 ,BR00\21050005 ,460.00
01-May-2021 ,BR00\21050007 ,460.00
01-May-2021 ,BR00\21050003 ,460.00
01-May-2021 ,BR00\21050033 ,320.00
01-May-2021 ,BR00\21050006 ,310.00
01-May-2021 ,BR00\21050004 ,2225.00
01-May-2021 ,BR51\21050009 ,460.00
];

T2:
Load *, Amount&'_'&Repeat as Amount_Marker;
Load If(Amount <> Peek(Amount), 1, Peek('Repeat')+1) as Repeat, Amount Resident T1 order by Amount;

o/p:

MayilVahanan_0-1627380786332.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

2 Replies
MayilVahanan

HI

Try like below

T1:
LOAD * INLINE [
DateCB,CBNumber ,Amount
01-May-2021 ,BR00\21050009, 320.00
01-May-2021 ,BR00\21050005 ,460.00
01-May-2021 ,BR00\21050007 ,460.00
01-May-2021 ,BR00\21050003 ,460.00
01-May-2021 ,BR00\21050033 ,320.00
01-May-2021 ,BR00\21050006 ,310.00
01-May-2021 ,BR00\21050004 ,2225.00
01-May-2021 ,BR51\21050009 ,460.00
];

T2:
Load *, Amount&'_'&Repeat as Amount_Marker;
Load If(Amount <> Peek(Amount), 1, Peek('Repeat')+1) as Repeat, Amount Resident T1 order by Amount;

o/p:

MayilVahanan_0-1627380786332.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
farru_scorpio
Contributor III
Contributor III
Author

Dear Mayil,

Perfect, a big thank you.