Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
felipe_oliveira
Contributor III
Contributor III

Actual Vs Plan in Pivot Table

Hi Masters,

I have 2 tables:

Table1

CityActual_$DateQuarterYearKey#
Miami3025/03/2018Q12018Miami|Q12018
Miami2015/04/2018Q22018Miami|Q22018
Miami2522/05/2018Q22018Miami|Q22018
Miami1513/08/2018Q32018Miami|Q32018
Miami2523/08/2018Q32018Miami|Q32018
Boston3013/02/2018Q12018Boston|Q12018
Boston1521/03/2018Q12018Boston|Q12018
Boston2515/05/2018Q22018Boston|Q22018
Boston1029/05/2018Q22018Boston|Q22018
Boston1522/08/2018Q32018Boston|Q32018

Table2

City_PlanPlan_$Quarter_PlanYear_PlanKey#
Miami60Q12018Miami|Q12018
Miami50Q22018Miami|Q22018
Miami70Q32018Miami|Q32018
Miami70Q42018Miami|Q42018
Boston60Q12018Boston|Q12018
Boston50Q22018Boston|Q22018
Boston70Q32018Boston|Q32018
Boston70Q42018Boston|Q42018

The link between the 2 tables is the Key# (City & '|' & QuarterYear).

In a Pivot table I would like to compare the Total Year Actual vs Total Year Plan

For example, Miami has the Year Actual = $115 (30+20+25+15+25)  and the Year Plan is $250 (60+50+70+70)

In the Pivot table my dimension is City from Table 1

For the total year Plan for Miami I have tried the following set analysis:

=Sum(Total<City>Plan_$)

=Sum({1<Year_Plan={2018},City_Plan=p(City)>}Plan_$)

=Sum({1<Year=,Quarter=,City=p(City_Plan)>}Plan_$)


None of the above worked. It shows as Total Plan for Miami $180 (sum of Q1 + Q2 + Q3). Even though Q4 does not exist in Table 1, I would like to include Q4 in the Total Plan for the year.


Please help me


Thanks

Felipe

1 Solution

Accepted Solutions
robert99
Specialist III
Specialist III

Hi Felipe

I always concatenate a budget to an actual (I don't join). With a set analysis field built in (say 'Budget' as GLBudgetActual and 'Actual' as GLBudgetActual)

And often add a date to the budget if its missing one. So it fits into the correct quarter if a calendar is done based on the date

As I had issues by joining when starting out

View solution in original post

6 Replies
robert99
Specialist III
Specialist III

Hi Felipe

I always concatenate a budget to an actual (I don't join). With a set analysis field built in (say 'Budget' as GLBudgetActual and 'Actual' as GLBudgetActual)

And often add a date to the budget if its missing one. So it fits into the correct quarter if a calendar is done based on the date

As I had issues by joining when starting out

Anonymous
Not applicable

Hello,

If you want to keep both table, then you can create a Link Table for all the common fields.

Add below script, then use City_L in Pivot Table dimension, and just use Sum(Actual_$) & Sum(Plan_$) in expression.

LinkTable:

LOAD City as City_L, 

     Quarter as Qtr_L,

     Year as Year_L,

     Key#

RESIDENT Table1;

Concatenate(LinkTable)

LOAD City_Plan as City_L,  

     Quarter_Plan as Qtr_L, 

     Year_Plan as Year_L,

     Key#

RESIDENT Table2; 

felipe_oliveira
Contributor III
Contributor III
Author

Hi Robert,

After concatenating, how can I avoid duplication of Plan_$ since in the Actual table there are more rows within the same quarter.

Please advise.

Regards

Felipe

neelamsaroha157
Specialist II
Specialist II

Concatenation will not duplicate the rows on the basis of Actual table rows.

check this -

robert99
Specialist III
Specialist III

Hi Felipe

Why would it duplicate?

But even if both revenue columns had the same name (say Revenue). Just use set analysis as explained above

For actual

Sum({$<GLBudgetActual = {Actual}>} Actual_$)

For Plan (I called it budget)

Sum({$<GLBudgetActual = {Budget}>} Plan_$)

Either filter as required. Or build in additional set analysis

NB Of course you would change the field names of plan to match with Actual (except maybe Plan_$) eg City_Plan to City. In this way filtering is easier

felipe_oliveira
Contributor III
Contributor III
Author

Thanks a lot Neelam for the sample. It made my life much easier to understand the solution.