Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am blocked with what seems an easy issue.
I load an Excel file that combine hours or amounts for several cost items.
I agree this is a strange set-up but that is how the client structured its data and have worked around all the way down except for a KPI and a bar chart formula.
The result look like this after loading my it in Qlikview and computing the TotalFigure, MonthlyCost, TotalCost, MonthlyPrice, TotalPrice
Cat. Expenditure | Cat | Start Date | End Date | MonthYear | NumberOfMonth | MonthlyFigure | TotalFigure | MonthlyCost | TotalCost | MonthlyPrice | TotalPrice |
1. Personnel | Engineer | 1/01/2016 | 31/12/2016 | 1/01/2016 | 12 | 50.00 | 600.00 | 6,501.83 | 78,021.93 | 6,989.46 | 83,873.58 |
1. Personnel | Expert | 1/01/2016 | 31/12/2016 | 1/02/2016 | 12 | 50.00 | 600.00 | 6,501.83 | 78,021.93 | 6,989.46 | 83,873.58 |
2. Direct Overhead | Engineer | 1/01/2016 | 31/12/2016 | 1/01/2016 | 12 | 10.00 | 120.00 | 1,300.37 | 15,604.39 | 1,397.89 | 16,774.72 |
2. Direct Overhead | Expert | 1/01/2016 | 31/12/2016 | 1/02/2016 | 12 | 10.00 | 120.00 | 1,300.37 | 15,604.39 | 1,397.89 | 16,774.72 |
3. Travel | 15/01/2017 | 16/01/2017 | 15/01/2017 | 1 | 6,000.00 | 6,000.00 | 6,000.00 | 6,000.00 | 6,579.00 | 6,579.00 | |
3. Travel | 23/03/2017 | 25/03/2017 | 23/03/2017 | 1 | 19,200.00 | 19,200.00 | 19,200.00 | 19,200.00 | 21,052.80 | 21,052.80 | |
5. Equipment | 1/04/2016 | 16/03/2017 | 1/02/2017 | 12 | 833.33 | 10,000.00 | 833.33 | 10,000.00 | 913.75 | 10,965.00 | |
5. Equipment | 1/04/2016 | 16/03/2017 | 1/03/2017 | 12 | 833.33 | 10,000.00 | 833.33 | 10,000.00 | 913.75 | 10,965.00 | |
6. Dissemination/Communication | 1/10/2016 | 31/12/2016 | 1/11/2016 | 3 | 333.33 | 1,000.00 | 333.33 | 1,000.00 | 365.50 | 1,096.50 | |
6. Dissemination/Communication | 1/10/2016 | 31/12/2016 | 1/12/2016 | 3 | 333.33 | 1,000.00 | 333.33 | 1,000.00 | 365.50 | 1,096.50 | |
7. Miscellaneous | 1/05/2016 | 31/07/2016 | 1/06/2016 | 3 | 1,000.00 | 3,000.00 | 1,000.00 | 3,000.00 | 1,096.50 | 3,289.50 | |
7. Miscellaneous | 1/05/2016 | 31/07/2016 | 1/07/2016 | 3 | 1,000.00 | 3,000.00 | 1,000.00 | 3,000.00 | 1,096.50 | 3,289.50 | |
8. Risk | 1/01/2016 | 31/12/2016 | 1/11/2016 | 12 | 1,000.00 | 12,000.00 | 1,000.00 | 12,000.00 | 1,096.50 | 13,158.00 | |
8. Risk | 1/01/2016 | 31/12/2016 | 1/12/2016 | 12 | 1,000.00 | 12,000.00 | 1,000.00 | 12,000.00 | 1,096.50 | 13,158.00 | |
4. External Services | 15/04/2016 | 28/04/2016 | 15/04/2016 | 1 | 10,000.00 | 10,000.00 | 10,000.00 | 10,000.00 | 10,965.00 | 10,965.00 | |
4. External Services | 1/07/2018 | 4/07/2018 | 1/07/2018 | 1 | 2,400.00 | 2,400.00 | 2,400.00 | 2,400.00 | 2,631.60 | 2,631.60 |
While I get want I want in a table, I can't manage to compute the sum of monthly cost in a KPI box or even in a bar chart.
The issue is that if Cat. Expenditure is 1. Personnal or 2. Direct Overhead, I need to apply an hourly rate [Hourly rate] from another table - see attached file - to transform the MonthlyFigure (which represents hours for those items) into a money amount. I need here to account for the Cat profile to select the right rate comprised in the Rate sheet.
But for all other cost items (3. Travel, 5. Equipment, ...), the MonthlyFigure is already an amount so I just need to sum up the amount.
I tried this formula but it does not work:
if([Cat. Expenditure]='1. Personnel (cat. PSS form 1)',sum(MonthlyFigure*[Hourly rate])
+
if([Cat. Expenditure]='2. Direct Overhead (cat. PSS form 9)',sum(MonthlyFigure*[Hourly rate])
+
sum(MonthlyFigure)))
Same issue in a bar chart. I do not get the right value, unless I include Cat. Expenditure as a dimension.
Can you help me solve this issue?
Million thanks Community guys 🙂
Try embedding the if() within the sum() aggregation function
sum( if( Match( [Cat. Expenditure],'1. Personnel (cat. PSS form 1)','2. Direct Overhead (cat. PSS form 9)'), MonthlyFigure*[Hourly rate]))
+
sum(MonthlyFigure)))
if([Cat. Expenditure]='1. Personnel (cat. PSS form 1)',sum({<[Cat. Expenditure]={'1. Personnel (cat. PSS form 1)'}>}MonthlyFigure*[Hourly rate])
+
if([Cat. Expenditure]='2. Direct Overhead (cat. PSS form 9)',sum({<[Cat. Expenditure]={'2. Direct Overhead (cat. PSS form 9)'}>}MonthlyFigure*[Hourly rate])
+
sum(MonthlyFigure)))
Have you considered applying the rates during the load process. First load the rate table with a mapping load, then load the detail.Something like:
MapRates:
Mapping LOAD ....
FROM Rates....;
Detail:
LOAD ...
If(WildMatch([Cat. Expenditure], '1.*', '2.*'), ApplyMap('MapRates', [Cat. Expenditure]), 1) * MonthlyFigure) As MonthlyCost,
...
Then there is no need for complex expressions in the front end.
I am sorry, this does not work Swuehl. I cannot get a result with this.
Looking at the expression, you do not have a sum prior MonthlyFigure*[HOurly rate] while you have one in front of MonthlyFigure, any reason why?
Hi Jonathan,
I very much like the approach proposed.
My only issue is that this comes in combination with calculation that distribute an amount over a variable amount of month.
I tried to make it work in my script but this does not work, any chance you can help me fix this?
Here is the script:
MapRates:
LOAD Cat,
//[Basic hourly rate],
//[Direct overhead],
[Hourly rate]
FROM
...
tabAmount:
LOAD
[PROJECT NAME :],
[DEPARTMENT :],
[Cat. Expenditure],
Title,
Cat,
Activity,
WP as ESSP_WP,
[Start Date],
MonthName([Start Date]) as MonthStart,
[End Date],
Monthname([End Date]) as MonthEnd,
Days,
(Year([End Date])*12 + Month([End Date]))-(Year([Start Date])*12 + Month([Start Date]))+1 as NumberOfMonth,
[Number/amount] as TotalFigure,
RecNo() as ID,
[Number/amount]/((Month([End Date])-Month([Start Date]))+12*(Year([End Date])-Year([Start Date]))+1) as MonthlyFigure,
If(WildMatch([Cat. Expenditure], '1.*', '2.*')>0, ApplyMap('MapRates', Cat), 1) * ([Number/amount]/((Month([End Date])-Month([Start Date]))+12*(Year([End Date])-Year([Start Date]))+1)) As MonthlyCost,
AddMonths([Start Date],IterNo()-1) as MonthYear
FROM
...
While AddMonths([Start Date],IterNo()-1)<[End Date];
tabMonths:
LOAD AddMonths(MinMonth,IterNo()-1) as MonthYear
While AddMonths(MinMonth,IterNo()-1)<=Today();
LOAD Min(MonthYear) as MinMonth
Resident tabAmount;
There is a sum() for aggregation, I just embedded the if() statement in the sum():
sum(
if( Match( [Cat. Expenditure],'1. Personnel (cat. PSS form 1)','2. Direct Overhead (cat. PSS form 9)'), MonthlyFigure*[Hourly rate])
)
I noticed that I left over some closing brackets at the very end of the expression which shouldn't be there, I think you have noticed and removed them?
What I don't get there is how it translate the fact that I need the following:
adding
MonthlyFigure*[Hourly rate] in case of personnel cost
to
Travel or other type of costs if not personnel
If I analyse your proposed expression, I get the following 'excuse my lack of scripting science 🙂
we sum
if personnel cost (1.* or 2.*), we multiply by hours
if non personnel cost, we need to still consider the personnel costs and add the travel,... cost
So, it not one or the other, it is both.
And when I try, I don't get values.
Could your genius help me out of here?
Ok, the case for 3 and above could be included into the THEN branch of the IF() statement:
=sum( if( Match( [Cat. Expenditure],'1. Personnel','2. Direct Overhead'), MonthlyFigure*[Hourly rate], MonthlyFigure))
It still does not work Swuehl.
Should I add an aggr in there so QlikView understand that he needs to sum up across all Cat. Expense?
One thing to precise is that the [Hourly rate] varies per Cat (not Cat. Expense).