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
LyonsBI_BRL
Helper III
Helper III

Calculate Revenue per month based off number of hours

I'm currently working through a problem that will give me the correct RevenuePerMonth based off the number of workable hours and workdays each month. Each person has a [dateBegin] and a [dateEnd] for when they will complete their work with the company. Below, the formula gives me the revenue generate for that person for the remaining months that they have.

Computed Rev = VAR _Billablehours = [Forecast Workable Hours]
VAR _ClientBillRate = [clientBillRate]
VAR _CurrentMonth = DATE(YEAR(TODAY()), MONTH(TODAY()),1)
VAR EndDate = [dateEnd]
VAR BeginDate = [dateBegin]
VAR NumberWorkDays = CALCULATE( COUNTROWS('Date'), DATESBETWEEN('Date'[Date], _CurrentMonth, EndDate ), 'Date'[Weekday] = TRUE || 'Date'[Public Holidays] <> 0)

RETURN

IF ( ISBLANK (NumberWorkDays), 0, NumberWorkDays) * [hoursPerDay] * _ClientBillRate

 

Now in order ot find the number of workable hours, I use the following calculated formula below. Which gives me both my number of billable hours and/or billable days excluding weekends and holidays.

Forecast Workable Hours = 
VAR _MonthStart = DATE(YEAR(TODAY()), MONTH(TODAY()),1)
VAR _MonthEnd = EOMONTH ( _MonthStart , 12 )
VAR _dateBegin = [dateBegin]
VAR _dateEnd = [dateEnd]
VAR _StartDate = IF ( _dateBegin >= _MonthStart , _dateBegin , _MonthStart )
VAR _EndDate = IF ( _dateEnd <= _MonthEnd , _dateEnd , _MonthEnd )
VAR _NumberWorkDays = CALCULATE( COUNTROWS('Date'), DATESBETWEEN('Date'[Date], _StartDate, _EndDate), 'Date'[Weekday] = TRUE || 'Date'[Public Holidays] <> 0)

RETURN 

IF ( ISBLANK (_NumberWorkDays), 0, _NumberWorkDays) * [hoursPerDay]

 

My problem is, I'm needing to calculate for each row, the revenue generated each month based off the number of workable days and/or hours for that person based off their billable rate. The formulate below though, unfortunately what it's doing is it's dividing up the remaining number of months for that user and dividing it, giving me the same revenue every month which isn't what I want as some months have more or less workable days / or hours.

 

RevenuePerMonth = 'Revenue'[Computed Rev]/(DATEDIFF(DATE(YEAR(TODAY()), MONTH(TODAY()),1), 'Revenue'[dateEnd],MONTH)+1)

So instead of it looking like this

LyonsBI_BRL_0-1636272506701.png

It needs to look more like this

LyonsBI_BRL_1-1636273462325.png

I know it's possible just I need some help on how to write this in DAX. Any help would be greatly appreciated. 

 

Thanks!

 

 

 

 

 

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @LyonsBI_BRL 

 

From your second image, RevenueforMonth = Workable Hours * BillRate. While in the first image, the [Forecast Workable Hours] returns the same 1400 value in each row. Is it getting the correct result? If [Forecast Workable Hours] already returns the correct result, why not creating a calculated column using [Forecast Workable Hours] * [clientBillRate] to get the expected result?

 

Best Regards,
Community Support Team _ Jing

VijayP
Super User
Super User

@LyonsBI_BRL 

you must have that column in your Datedim Table. Create one and then you will not get this error




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


VijayP
Super User
Super User

@LyonsBI_BRL 

CALCULATE('Revenue'[Computed Rev]/(DATEDIFF(DATE(YEAR(TODAY()), MONTH(TODAY()),1), 'Revenue'[dateEnd],MONTH)+1),
FILTER(ALL(DATESdim),VALUES(Month &YEar))

Try this




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Doesn't seem to be working or is Values looking for a column?

 

LyonsBI_BRL_0-1636347286858.png

 

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.