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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
InterSimi
Helper II
Helper II

Calculate age of item based on dates after 1/1/2018

Hi,

 

I wish to add a calculated column in my PowerBI report, which calculates the hours saved based on the date provided and hourly savings up until todays date. The only caveat is that I only need the hours to be calculated for 2018.

 

We have a Sharepoint list, which has columns for "start date" and monthly savings (in hours). However we have projects which go back a few years, which I do not wish to include.

 

The DAX I have for the project run time is:

 

Project Run Time = 
IF('LEANSavings '[OccurenceValue] = "Re-Occurring Savings", 
    (TODAY() - 'LEANSavings '[SavingsStartDate].[Date])/30, 
    1)

I wish to add something to state that if

LEANSavings '[SavingsStartDate].[Date]  

 is before 1/1/2018, then the date should be 1/1/2018

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Project Run Time = 
VAR startdate = IF('LEANSavings '[SavingsStartDate].[Date] < DATE(2018,1,1),DATE(2018,1,1),'LEANSavings '[SavingsStartDate].[Date])
RETURN
IF('LEANSavings '[OccurenceValue] = "Re-Occurring Savings", 
    (TODAY() - startdate)/30, 
    1)


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Project Run Time = 
VAR startdate = IF('LEANSavings '[SavingsStartDate].[Date] < DATE(2018,1,1),DATE(2018,1,1),'LEANSavings '[SavingsStartDate].[Date])
RETURN
IF('LEANSavings '[OccurenceValue] = "Re-Occurring Savings", 
    (TODAY() - startdate)/30, 
    1)


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

That is fantastic Greg, thank you.

 

I did start to do something very similar, buit keep forgetting whether to use 'Let' or Var'. Occassionally when I type in Var, PoiwerBI only gives me options like Var.P

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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