cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

## date difference per value

Hello dear Power BI Community

Following problem:

I would like to add in Power BI the 3th column given these informations:

It should calculate the date difference per Product off the row above.

 Product Date Date_Difference_per_Product A 01.06.2022 0 B 09.06.2022 0 A 10.06.2022 9 A 15.06.2022 5 B 20.06.2022 11 B 25.06.2022 5

Thank you very much for your contribution.

Cheers

qwertzuiop

1 ACCEPTED SOLUTION
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

``````Date Diff per Product CC =
VAR _previousdate =
MAXX (
FILTER (
Data,
Data[Product] = EARLIER ( Data[Product] )
&& Data[Date] < EARLIER ( Data[Date] )
),
Data[Date]
)
RETURN
IF ( _previousdate = BLANK (), 0, INT ( Data[Date] - _previousdate ) )
``````

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Visit my LinkedIn page by clicking here.

Schedule a meeting with me to discuss further by clicking here.

3 REPLIES 3
Solution Sage

@qwertzuiop try this

`Column = var _A = 'yourTable'[Product]         var _B = CALCULATE(MAX('yourTable'[Date]),FILTER('yourTable','yourTable'[Date] <EARLIER('yourTable'[Date])),'yourTable'[Product] = _A)         var _C = DATEDIFF('yourTable'[Date],_B,DAY)         return         if(_C = BLANK(),0,abs(_C)`
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

``````Date Diff per Product CC =
VAR _previousdate =
MAXX (
FILTER (
Data,
Data[Product] = EARLIER ( Data[Product] )
&& Data[Date] < EARLIER ( Data[Date] )
),
Data[Date]
)
RETURN
IF ( _previousdate = BLANK (), 0, INT ( Data[Date] - _previousdate ) )
``````

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Visit my LinkedIn page by clicking here.

Schedule a meeting with me to discuss further by clicking here.

Helper I

Dear Jihwan_Kim

PREVIEW

You solution here should work with my problem here as posted on the Forum , but I cannot get it to work. Should you have a moment to spare, may I ask you to please have a look? The applicable Power BI file is here.

I sincerely thank you!

W

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors