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
Anonymous
Not applicable

Current Month and YTD Calculation

I have three tables: Business Calendar, Cost, and Project with sample data and column structure provided below:Calendar.PNG

 

Cost.PNG

 

Project.PNG

I want to create a measure to calculate monthly cost such that if today is between current month business day and next month business day, then calculate total cost for previous month. For example, today is between March business day, and next month business day, so calculate Feb cost for each project. Also, if I refresh data next month on April business day (and between this day and May business day), the cost should automatically reflect for the month of March. I also want to do the same for YTD. Any helps would be appreciated!

 

2 REPLIES 2

Hi Nick,

 

The below measure basically sums up all the cost as per current month i.e. business calendar based on your system date.

 

TOTAL_EXPENSE_TD = CALCULATE(SUM(COST[COST]),COST[MONTH]<MONTH(TODAY) && COST[YEAR]=YEAR(TODAY()))

 

Regards,

Saurabh Kedia

v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may try to use RANKX Function and take a look at https://www.sqlbi.com/articles/lookup-multiple-values-in-dax/.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.