Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
ramp1985
Contributor II
Contributor II

Concat if expression

Hi Guys,

I'm sure its simple, but can't find the solution.

I have a dataset like this:

Columns:

Ordernumber-Customer-Month-Sales Week-Sales Amount

So, now i want in my table instead of having one line for each month, I want to use Concat to show the months of all orders in the same cell, if sales week was last week.

So it should Concat(combine) the months from all orders on customer level, that was in last week. 

Tried something like: 

=concat(Distinct Aggr(if(

[Customer] = {'=

Sum({<[Sales Week]={$(=Week(today())-1)}>} '} Sales Amount)

>0'}

, Month), Month), '-')

Expected Result:

ramp1985_0-1615287994171.png

Hope you can help 🙂

Labels (3)
1 Solution

Accepted Solutions
Or
MVP
MVP

Then perhaps I misunderstood your request - my understanding was that  Customer 1 *should* show the months on previous orders, because they made an order in the past week? Wouldn't the months for the past week always be just e.g. March for today (or occasionally, it might cross two months)?

If you want a field iterated only for orders from the past week, there's probably a cleaner way to write it with set analysis, but I think you should be able to use:

Concat(distinct If([Sales Week]=Week(today())-1,[Sales Month]),'-')

Adjust the condition/fields if I wrote them incorrectly, of course.

 

View solution in original post

5 Replies
Or
MVP
MVP

If I understood your requirement correctly...

if(Sum({<[Sales Week]={$(=Week(today())-1)}>} '} Sales Amount)>0,Concat(distinct Month,'-'))

Syntax may need tweaking since I can't test it.

ramp1985
Contributor II
Contributor II
Author

Hi again,

Thanks for quick help.

Almost there, but. Seems like it also includes months when the costumer has orders older than last week.?  

For example customer 1 has made an order 5 weeks ago. The months on that order is also included, as the customer also has orders last week.

So thats why I think I need to use Aggr but I might be wrong?

Or
MVP
MVP

Then perhaps I misunderstood your request - my understanding was that  Customer 1 *should* show the months on previous orders, because they made an order in the past week? Wouldn't the months for the past week always be just e.g. March for today (or occasionally, it might cross two months)?

If you want a field iterated only for orders from the past week, there's probably a cleaner way to write it with set analysis, but I think you should be able to use:

Concat(distinct If([Sales Week]=Week(today())-1,[Sales Month]),'-')

Adjust the condition/fields if I wrote them incorrectly, of course.

 

ramp1985
Contributor II
Contributor II
Author

Much better. Last issue, how do I ensure that the earliest month will come first and the latest month will come last? 

Example: MAY-MAR should be MAR-MAY

ramp1985_0-1615295309122.png

 

Or
MVP
MVP

You can apply a sort order in concat(). If your months are duals, you should just be able to use the month. If not, you'll have to use a corresponding MonthNum field or some other mechanism.