Forum Discussion
Calculating cumulative Months by project code
- 8 years ago
Hi,
I have now managed to create the formulas :) Thank you
- 8 years ago
The below formula seems to work; I created a sum column calculating figures by month, then created another colum to filter by project;
Monthly Sum = CALCULATE(SUM(Financials[Actual Monthly Cost]),FILTER(ALL(Financials),Financials[Date] <=TODAY()))
By Project = CALCULATE(SUM(Financials[Actual Monthly Cost]),ALLEXCEPT(Financials,Financials[ProjectCode],Financials[Monthly Sum]))
Hey,
thanks for sharing sample data, maybe you might consider to share the link using a normal post and not a private message :-)
Nevertheless ...
I created a new column that just contains a date datatype using this statement, because your sample data did not contain a column called "Month Number":
A Date Column =
DATE('Financials'[Year]
,SWITCH('Financials'[Month]
,"January",1
,"February",2
,"March",3
,"April",4
,"May",5
,"June",6
,"July",7
,"August",8
,"September",9
,"October",10
,"November",11
,"December",12)
,1)After that I created another calculated column, that acumulates the values from the column Actual Monthly Cost:
**bleep** Actual Monthly Cost =
var currentDate = 'Financials'[A Date Column]
var currentProjectCode = 'Financials'[ProjectCode]
return
CALCULATE(
SUM('Financials'[Actual Monthly Cost])
,FILTER(ALL('Financials')
,Financials[A Date Column] <= currentDate
//&& 'Financials'[ProjectCode] = currentProjectCode
)
)I was'n sure if you wanted this calculation per Projectcode (probable: inspecting the formula you provided). If this is the case, just remove the comment sign // from this line
//&& 'Financials'[ProjectCode] = currentProjectCode
If you do not need the line, you can remove the following lines:
...
var currentProjectCode = 'Financials'[ProjectCode]
...
//&& 'Financials'[ProjectCode] = currentProjectCode
...Here is a little screenshot:
As you can see, there is an issue with the February issues, this will be automatically resolved if the acumulation has to happen for each Projectcode separately. If not the calculation will become much more sophisticated, and can't be achieved using a calculated column. And you also have to provide an explanation about the nature of your sample data and provide the expected result that matches your sample data.
Regards
Tom
Many thanks for your response. I have managed to calculate a monthly sum of the Actual Monthly Cost now however, still unable to filter the Actual Monthly cost by project code (so currently it is showing the figure as a sum of all projects). I am unable to get the last part of the formula to work; //&& 'Financials'[ProjectCode] = currentProjectCode
- Anonymous8 years agoNot applicable
Bryony,
Could you please share sample data of your table and expected result through online service such as OneDrive?
Regards,
Lydia- Bryony8 years agoFrequent Visitor
Hi,
I have now managed to create the formulas :) Thank you
- TomMartens8 years agoSuper User
Hey Bryony,
this is a great!
Can you please post your solution and mark it as answer, this will help all the other community members (including me) a lot!!
Thanks
Tom