cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
bchager6
Post Prodigy
Post Prodigy

Adding a whole number to a date in a related table

Hi All...

 

I am trying to add a whole number that exists in its own column, via a calculated column, to a date in a related table based on project phases, with no success. If the phase is Execute, the New Start Date shouldn't change, if Plan, add the whole number to the Start Date and return a New Start Date. The expression always returns the same date, or a blank. Can anyone see where the flaw is?

Additional info; there are other project phases in the related table whose dates should remain the same.

New Start Date =
IF(RELATED('RelatedTable'[Phase]) = "Execute",
IF(RELATED('RelatedTable'[Phase]) = "Plan",
DATEADD('RelatedTable'[Start Date],'CurrentTable'[Total Time Column],DAY),
RELATED('RelatedTable'[Start Date])))
 
Thanks in advance and kudos to anyone who can help me figure this one out!
4 REPLIES 4
AlB
Super User
Super User

Hi @bchager6 

Try this

New Start Date =
IF(RELATED('RelatedTable'[Phase]) = "Execute",
IF(RELATED('RelatedTable'[Phase]) = "Plan",
DATEADD(RELATED('RelatedTable'[Start Date]),'CurrentTable'[Total Time Column],DAY),
RELATED('RelatedTable'[Start Date]))

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs

Cheers 

SU18_powerbi_badge

@AlB  Thank you. I tried that and Power BI returns an error: "The first argument to 'DATEADD' must specify a column."

The two tables I'm working with are related via a cross filter in both directions if that's relevant to the error.

@bchager6 

You should stay away from bidirectional relationships unless there's a very good reason to use them and, more importantly, you know very well what you are doing.  Try this and if it doesn't work please share a sample of your tables and provide an example to show the expected result based on that.

New Start Date =
IF(RELATED('RelatedTable'[Phase]) = "Execute",
IF(RELATED('RelatedTable'[Phase]) = "Plan",
RELATED('RelatedTable'[Start Date]) + 'CurrentTable'[Total Time Column],
RELATED('RelatedTable'[Start Date]))

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

@AlBI made one tweak and realized I overcomplicated the expression with a nested IF when I didn't need to, given the only dates that need to change are for those projects that are in the Plan phase. Placing the RELATED function at the end of the 3rd row in the expression helped also.

New Start Date =
IF(RELATED('RelatedTable'[Phase]) = "Plan",
RELATED('RelatedTable'[Start Date]),
'CurrentTable'[Total Time Column] + RELATED('RelatedTable'[Start Date])
)

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors