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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
dnaman
Helper I
Helper I

Calculate rate based on dates and expected value

Hi All,

 

I would like to create a new column/measure, called "Revenue/Month" that is based on 3 columns in my table:

 

Weighted Value

Revenue Start Date

Revenue End Date

 

It should be weighted value / total # of months between the two dates

4-5-2018 4-47-47 PM.jpg

 

 

I've looked at this forum post here, but i'm having trouble doing it step by step (first, creating a new column to calculate months keeps throwing me errors (column cannot be found..))

 

https://community.powerbi.com/t5/Developer/Number-of-Months-between-two-dates/m-p/90008

 

Any help is appreciated.

 

Basically i want to come up with an expanded data set that lists a row into multiple rows, each differing by the revenue month, and then i will ultimately create a chart showing revenue by month.

 

Many thanks in advance

 

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @dnaman

 

Here is a calculated column that might work in DAX

 

Column = 
VAR StartYear = LEFT('Table1'[Expected Revenue Start Year-Mon],4)
VAR StartMonth = RIGHT('Table1'[Expected Revenue Start Year-Mon],2)

VAR EndYear = LEFT('Table1'[Expected Revenue End Year-Mon],4)
VAR EndMonth = RIGHT('Table1'[Expected Revenue End Year-Mon],2)

VAR MonthsDiff = DATEDIFF(
                        DATE(StartYear,StartMonth,1) ,
                        DATE(EndYear,EndMonth,1) ,
                        MONTH)

RETURN DIVIDE('Table1'[Weighted Value],MonthsDiff,BLANK())

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @dnaman

 

Here is a calculated column that might work in DAX

 

Column = 
VAR StartYear = LEFT('Table1'[Expected Revenue Start Year-Mon],4)
VAR StartMonth = RIGHT('Table1'[Expected Revenue Start Year-Mon],2)

VAR EndYear = LEFT('Table1'[Expected Revenue End Year-Mon],4)
VAR EndMonth = RIGHT('Table1'[Expected Revenue End Year-Mon],2)

VAR MonthsDiff = DATEDIFF(
                        DATE(StartYear,StartMonth,1) ,
                        DATE(EndYear,EndMonth,1) ,
                        MONTH)

RETURN DIVIDE('Table1'[Weighted Value],MonthsDiff,BLANK())

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

That works, thanks!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.