Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jaqz81
New Member

Summing YTD of measure calculated on a monthly basis

Hello all. I am quite new to Power BI and DAX. I've been browsing the forum for an answer to my scenario, and have not been able to find one (although most likely I should have). My scenario is this: we have a management fee which is calculated on a monthly basis using a percentage of headcount in different offices. Example: allocatable costs are in total 100 in month 1, of which office A has paid 30 and office B has paid 70. Headcount is 40% in office A and 60% in office B. In such a case the management fee (net share of costs less costs already paid) would be 10 to be paid by A in month 1.

 

Now, I have been able to create a measure which calculates the management fee correctly for the selected month. However I do not understand how to calculate this year-to-date. The calculation needs to take place on a monthly basis i.e. YTD needs to be sum of January, February, etc. instead of calculated from YTD allocatable cost  because headcount and costs vary from month to month. How do I tell the measure to calculate YTD so that January costs are allocated based on January headcount, February costs based on February headcount, etc. Does this make sense? I will paste my measure snippet here so perhaps you get a better understanding of what I mean. In the below code GL Natural=9600 is where I am deriving the headcount percentage, and AlreadyPaid works because I have forced a selection of a single office in the report filters.

 

ManagementFeeMeasure =
VAR currentMonth =
MONTH (max(DW_DimDate[FullDate]))
VAR currentYear =
YEAR (max(DW_DimDate[FullDate]))

VAR NetShare =
calculate(
sum(DW_FactValues[FactValue]);DW_FactValues[Type]="Actual";DW_GLType[GLTypeName]<>"Headcount";all(DimGLOfficeGrouping[Country]);filter(all(dW_DimDate[FullDate]);month(DW_DimDate[FullDate]) = currentMonth && YEAR(DW_DimDate[FullDate]) = currentYear)
) *
divide(
CALCULATE(
SUM (DW_FactValues[FactValue]); DimGLNatGroupingMF[GL Natural]=9600;filter(all(DW_DimDate[FullDate]);month(DW_DimDate[FullDate]) = currentMonth && YEAR(DW_DimDate[FullDate]) = currentYear))
;100
)

VAR AlreadyPaid =
CALCULATE (
SUM (DW_FactValues[FactValue]);
FILTER (
ALL (DW_DimDate);
MONTH (DW_DimDate[FullDate]) = currentMonth
&& YEAR (DW_DimDate[FullDate]) = currentYear
);
DW_FactValues[Type]="Actual";DW_GLType[GLTypeName]<>"Headcount"
)
RETURN
NetShare - AlreadyPaid

 

Any help greatly appreciated!

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Jaqz81,

 

Could you please share you sample data or pbix to me so that I can help with it?

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

 

Hello Frank,

 

Thanks for answering! I'm afraid I cannot share the .pbix as I do not know how to make the somewhat sensitive data anonymous. Any other way of helping you help me? I don't suppose the below screenshot of relationships aids at all?

 

Regards,

 

Jari

 


RelationshipsRelationships

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.