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: 
konHi
Partner - Contributor III
Partner - Contributor III

Join / Merge actual and target values

Hi,

i have the following problem and don't see the solution how to solve it (tried a lot of things but still don't get it).

I have two tables:

1: actual sales

2: targets

Actual Sales:

RowNr.Dep.Main. DepAreaPlantModellSales

1

A

BBCDE1

-

5
2ABBCDF1-5
3ABBFDE1-12
4ABBFDE2-5
5BBBFDE--16
6ABC--

Mod1

17

2: Target

RowNr.Dep.Main. DepAreaPlantModellTarget

11

A----12
12ABB---8
13-BB---9
14ABBFDE--13
15----Mod15
16-BC-1-8
17A--1-12

As a result I want to have following in Pivot Table:

RowNr.Dep.Main. DepAreaPlantModellSalesTarget
21A----4412
22ABB---278
23-BB---439
24ABBFDE--1713
25----Mod1175
26-BC-1-08
27A--1-2212
28ABB-1-22-
29-BC--Mod117-

There is no real hierarchy in the structure. I always want to have the sum(Sales) and the Target at the specific level. (RowNr. is only for reference. )

For Example:

Example RowNr:Pivot DimensionsSales ExpressionTarget Expression
22Dep. -> main.Dep: A->BB=sum(Row1+Row2+Row3+Row4) = 27=Target from Row 12 = 8
24Dep. -> main.Dep ->Area: A->BB-FDE=sum(Row3+Row4) = 17=Target from Row 14 = 13
26Main.Dep ->Plant=sum(Not Available) = 0=Target from Row 16 = 8
28Dep. -> Main.Dep. -> plant0sum(Row1+ Row2 + Row3) = 22=Target now available = -

I hope you understand my problem. I am very grateful for you answers. Please find attached the QVW with the data. thank you very much

14 Replies
Anonymous
Not applicable

Have you tried to concatenate Sales and Target?

See attached

konHi
Partner - Contributor III
Partner - Contributor III
Author

Hi Michael,

thank you for the answer. The problem is, I am not allowed to aggregate the target through sum. I have to pick the right target at the right level. In you app, i get for Dep: A Target 24 or 45. But I should pick the RowNr21 and show as Target: 12.

Colin-Albert
Partner - Champion
Partner - Champion

Is there another field that can be used to associate the rows you are summing for the Sales value and the Target rows instead of trying to associate the data by row numbers. - A WeekNo, or Period//Year would be the ideal option.

If you could concatenate the Sales & Target data , then you could simply sum the Sales and Target data against a Period field, to give the chart you are looking for.

Concatenating Sales and Target data is the simplest solution to ensure that you do not have an incorrect join causing target values to be counted multiple times.

sunny_talwar

You are not going to like this, but it kind of does the job for you:

Capture.PNG

=If(Len(Trim(Main.Dep)) = 0 and

  Len(Trim(Plan)) = 0 and

  Len(Trim(Modell)) = 0 and

  Len(Trim(Area)) = 0, Sum(TOTAL <Dep.> Sales),

If(Len(Trim(Dep.)) = 0 and

  Len(Trim(Plan)) = 0 and

  Len(Trim(Modell)) = 0 and

  Len(Trim(Area)) = 0, Sum(TOTAL <Main.Dep> Sales),

If(Len(Trim(Dep.)) = 0 and

  Len(Trim(Plan)) = 0 and

  Len(Trim(Main.Dep)) = 0 and

  Len(Trim(Area)) = 0, Sum(TOTAL <Modell> Sales),

If(Len(Trim(Plan)) = 0 and

  Len(Trim(Modell)) = 0 and

  Len(Trim(Area)) = 0, Sum(TOTAL <Dep., Main.Dep> Sales),

If(Len(Trim(Main.Dep)) = 0 and

  Len(Trim(Modell)) = 0 and

  Len(Trim(Area)) = 0, Sum(TOTAL <Dep., Plan> Sales),

If(Len(Trim(Modell)) = 0 and

  Len(Trim(Area)) = 0, Sum(TOTAL <Dep., Main.Dep, Plan> Sales),

If(Len(Trim(Modell)) = 0 and

  Len(Trim(Plan)) = 0, Sum(TOTAL <Dep., Main.Dep, Area> Sales),

If(Len(Trim(Area)) = 0, Sum(TOTAL <Dep., Main.Dep, Plan, Modell> Sales), Sum(Sales)))))))))

You may need to add more If statements here, but it kind of get the output you are looking for.

Attaching the qvw for reference as well.

Best,

Sunny

konHi
Partner - Contributor III
Partner - Contributor III
Author

Hi Sunny,

it seems to work. quit complicated but my first testing was positive. Thank you very much!!!

I will keep you up to date.

Have a nice day

[edit]: ist that right, that i will have 2^[number of fields] possibilities for the if clause? At the end i will have 12 Fields with targets in every possible combination = 2^12 = 4096

sunny_talwar

Yup and that was the reason I said that you are not going to like this formula. Am sure there must be a better way to do this, but I just don't know how to do it

Best,

Sunny

konHi
Partner - Contributor III
Partner - Contributor III
Author

Hi Sunny,

I tried to make the expression dynamic. Find the example attached. The "String" in the concatenated row seems to work but the evaluated row does not evaluate the string properly. Do you see any mistakes?

Thank you,

Konstantin

sunny_talwar

I really liked the idea of what you are doing, but I think the problem is that the expression is always evaluated as false and giving you an output for the false statement which is Sum(Sales). Take a look at the image below:

Capture.PNG

We somehow need to make it to evaluate the if statement and give an output. But I really liked the idea of what you have done.

Best,

Sunny

sunny_talwar

I kind of understand the problem now. Your evaluated Sales new is getting evaluated at the chart level instead of row level. The way I was able to figure this out was by selecting Main.Dep BB and seeing the result as 43 instead of 0 when everything else was null (See the image below)

Capture.PNG