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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
cocoloco79
Helper III
Helper III

Subtracting days form date

Hi there

 

I have two tables for witch I have created a relationship that looks at crop.

One table holds a harvest date column and the other table holds number of days to grow plants.

 

I like to subtract the number of days from the harvest date to calculate the planting date.

Can anyone help me with this?

date calc.png

 

 

3 ACCEPTED SOLUTIONS
cocoloco79
Helper III
Helper III

Hi Steve, thank you but this didnt work. I get an error stating that the column gow time doesnt exist or there is a relationship missing. I did create the relationship, but it is not beeing picket up in the function.

I have attached the pbix, I hope you don't mind thinking a look.

grow time.pnghttps://drive.google.com/file/d/1uZFHig9Jnv_6R1n1EONixlZ8UNBZbciF/view?usp=sharing 

 

 

View solution in original post

Hey @cocoloco79 . The relationship you had was many-to-many which is problematic. I updated your .pbix and it is linked here

 

This was the relationship in your file:

SteveHailey_0-1641092816550.png

 

I use this code to create a bridge table:

 

Grow Times = ALL( BI_Planting_Master[CropName], BI_Planting_Master[CropGrowTime])

 

SteveHailey_1-1641092842998.png

 

And then updated the relationships:

SteveHailey_2-1641092883985.png

And then updated the fields in the table visual:

SteveHailey_3-1641093096533.png

 

Someone else may have a better way to do this.. but this is they way I know. Hope that works for you!

 

-Steve

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
cocoloco79
Helper III
Helper III

Hi Steve, thank you but this didnt work. I get an error stating that the column gow time doesnt exist or there is a relationship missing. I did create the relationship, but it is not beeing picket up in the function.

I have attached the pbix, I hope you don't mind thinking a look.

grow time.pnghttps://drive.google.com/file/d/1uZFHig9Jnv_6R1n1EONixlZ8UNBZbciF/view?usp=sharing 

 

 

Hey @cocoloco79 . The relationship you had was many-to-many which is problematic. I updated your .pbix and it is linked here

 

This was the relationship in your file:

SteveHailey_0-1641092816550.png

 

I use this code to create a bridge table:

 

Grow Times = ALL( BI_Planting_Master[CropName], BI_Planting_Master[CropGrowTime])

 

SteveHailey_1-1641092842998.png

 

And then updated the relationships:

SteveHailey_2-1641092883985.png

And then updated the fields in the table visual:

SteveHailey_3-1641093096533.png

 

Someone else may have a better way to do this.. but this is they way I know. Hope that works for you!

 

-Steve

SteveHailey
Solution Specialist
Solution Specialist

Hello,

One option is to create a calculated column in your Harvest Date table to pull in the grow time from the related table:

 

 

Grow Time = RELATED('Grow Times'[CropGrow Time] )

 

 

 Then add a calculated column to subtract the days:

 

 

Planting Date = 'Harvest Date'[Date] - 'Harvest Date'[Grow Time]

 

 

Then create a table visual to match your example:

SteveHailey_0-1641087234537.png

Here's a link to an example .pbix file.

 

-Steve

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.