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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Mahadevaraobc
Helper II
Helper II

Difference between date and run if

Hi i have the following sample table, and i want to achieve the following.Each product can have multiple event nos. 

a) Calculate date difference between 1st and last events for same product

b) Mark all event nos  more than 2 days and less than 30 days for same product as Re-Event, excluding 1st Event.

 

Product Event NoDate
Product 13663328-5017/27/2019
Product 14377204-5027/28/2019
Product 18524894-5017/29/2019
Product 19478521-5017/30/2019
Product 29478521-5026/15/2019
Product 29478521-5032/15/2019
Product 29478521-5078/15/2019
Product 39478521-5086/15/2019
Product 39478521-5095/27/2019
Product 39478521-5107/20/2019
Product 39478521-5117/27/2018
Product 39478521-5123/27/2019
Product 39478521-5143/28/2019
Product 39841725-5012/15/2019
Product 29841725-5026/16/2019
Product 29841725-5034/15/2019
Product 49841725-5053/27/2019
Product 49841725-5062/17/2019
Product 49841725-5073/24/2019
Product 40227975-5013/27/2019
Product 40227975-5026/15/2019
Product 40227975-5043/27/2019
Product 50227975-5067/27/2019
Product 50227975-5071/27/2019
Product 50495169-5017/27/2019
Product 50495169-5047/29/2019
Product 50495169-5057/30/2019
Product 50495169-5067/31/2019
Product 51160976-5016/15/2019
Product 51160976-5022/15/2019
Product 51160976-5032/17/2019
Product 51160976-5047/29/2019
Product 51160976-5057/30/2019
Product 51160976-5063/27/2019
Product 51160976-5073/27/2019
6 REPLIES 6
Nathaniel_C
Super User
Super User

Hi @Mahadevaraobc ,

Here you go. Will post code in a minute.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

Event span1.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Mahadevaraobc ,

 

Interesting issue, hope this helps.

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

Here is my pbix  https://1drv.ms/u/s!AgCd7AyfqZtExjCwBgNzr63TFQaz?e=dg6Nzh

 

First date = CALCULATE(MIN(Event[Date]),Event[Date],FIRSTDATE(Event[Date]))

Elapsed Time = Var StartDate = CALCULATE(MIN(Event[Date]),Filter(ALLSELECTED(Event),min(Event[Date])))


Return
DATEDIFF(StartDate,Event[First date],DAY)

Is Re-event = IF([Elapsed Time]>3&& [Elapsed Time]<30,"Re-Event","")
Event Span = DATEDIFF(FIRSTDATE(Event[Date]),LASTDATE(Event[Date]),DAY)

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you will check and get back...

Thanks Nathaniel_C,

 

This works but, there are few changes to be done, like.

  Product should not be single select, when i unselect all, first date should be taken based on product 1st date and last date should be max of that product date and not all product dates.

 

Nathaniel_C
Super User
Super User

Hi @Mahadevaraobc ,

 

Here is the event span, have to do something else, will be back.

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

 

Event Span = DATEDIFF(FIRSTDATE(Event[Date]),LASTDATE(Event[Date]),DAY)

 

Event span.PNG 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi Nathaniel_C,

 

Thanks for replying, this answers part of my question, could you help me with the other question...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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