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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
herbemischung
Resolver I
Resolver I

Calculating Age

Hi, I just started with Power BI and I tried to figure this out by myself, but I didn't find a solution yet, so I hope you can help me or show mit the thread I overlooked. Thanks in advance!

 

I have to calculate the Age of a Wineyard. The Year in which the Wineyard was bed out is just a Year in a Table like 1988.

In another Table I have a Date collum with a date for every action. Like Date <1.5.2015> action <mulch> or date <10.10.2015> action <harvest> and so on.

 

when  I set a filter on 2015 I need the difference in years between the filter and the year the wineyard was bed out.

2 REPLIES 2
herbemischung
Resolver I
Resolver I

never mind...

 

I haven't been sure, If the problem is that there are different dates in the form dd.mm.yyyy so I created a calculated collum:

year_solo = year(Pivot[date])

 

then i created this measure:

age= datediff(min('Schläge'[year1]);min(Pivot[year_solo]);DAY)

 

I still have no clue, why I have to use DAY, but thats why It hasn't been working 😉 

Anonymous
Not applicable

Hi @herbemischung,

Based on this official article, when using DATEDIFF function, we should specify scalar datetime value as start_date .

DATEDIFF(<start_date>, <end_date>, <interval>) 

In your scenario, 'Schläge'[year1]  column contains numeric value rather than datetime value, you would need to use the following formula to calculate age.
 
age= min('Schläge'[year1])- min(Pivot[year_solo])

Thanks,
Lydia Zhang

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.