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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mdrammeh
Helper III
Helper III

How to create a calculated field by date interval

I need help creating a calculated field in Power BI or Power Query for the following measures:

 

Projects Submitted 27 months prior to “Constructions start” date”

Projects Released 21 months prior to “Construction Year”( Construction Year is 3 years from today's date)

Projects Scheduled between 12-18 months prior to “Construction Year”

Scheduled 1 Year Prior to “Construction Start”

 

Assuming I have the above field names to complete my calculations. Keep in mind that I want o use networking days only  if possible. 

 


Thanks for all your help in advance. 

 

Mustaff

2 ACCEPTED SOLUTIONS

You can do sth very similar in DAX with DATEADD, e.g.

 

DATEADD( TheData[Date], -27, MONTH )

 

 

- however your overall scenario is not very clear (to me) - do you e.g. want to count projects?

 

Frank

View solution in original post

Ya this formula should work in Power BI without any change dude.

 

lets see my example .

 

But u have to create  calculated column in table . see the picture 

1.JPG

 

 

2.JPG

 

 

 

let me know if it is not helping u , i will help u , to reach your goal

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Can you provide some sample data and an explanation of "networking days"?

 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

In Excel it would translate to something like this:

 

=DATE(YEAR(B33),MONTH(B33)+27,DAY(B33))

=DATE(YEAR(B33),MONTH(B33)-27,DAY(B33))

 

Timeline.PNGData.PNG

 

I tried to copy and paste the example but it didn't work. I hope this helps.

 

Ya this formula should work in Power BI without any change dude.

 

lets see my example .

 

But u have to create  calculated column in table . see the picture 

1.JPG

 

 

2.JPG

 

 

 

let me know if it is not helping u , i will help u , to reach your goal

Thanks! The formula works but what if I want to create a lookup by duration from each date within the same column? Let's say I have a columns A,B, and C as my example where:

 

Column "A" = Start date

Column "B" = Finish Date

Column "C" = Duration

 

1. How can I calculate the duration by month between "A" and "B" to produce the count of month for each project. 

2. After Calculating the Duration, how can I use this Excel formula to group by days:

E.G.

=IF([@[Duration]]<1,"Less than 1 day",IF(AND([@[Duration]]>0,[@[Duration]]<56),"Between 1 and 55 days",IF(AND([@[Duration]]>55,[@[Duration]]<366),"Between 56 and 365 days","Greater than 365 days")))

You can do sth very similar in DAX with DATEADD, e.g.

 

DATEADD( TheData[Date], -27, MONTH )

 

 

- however your overall scenario is not very clear (to me) - do you e.g. want to count projects?

 

Frank

Thanks! The formula works but what if I want to create a lookup by duration from each date within the same column? Let's say I have a columns A,B, and C as my example where:

 

Column "A" = Start date

Column "B" = Finish Date

Column "C" = Duration

 

1. How can I calculate the duration by month between "A" and "B" to produce the count of month for each project. 

2. After Calculating the Duration, how can I use this Excel formula to group by days:

E.G.

=IF([@[Duration]]<1,"Less than 1 day",IF(AND([@[Duration]]>0,[@[Duration]]<56),"Between 1 and 55 days",IF(AND([@[Duration]]>55,[@[Duration]]<366),"Between 56 and 365 days","Greater than 365 days")))

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.