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
Anonymous
Not applicable

Retrieve the first date of the item's dissapearence

 

Hi,

 

I have the below table for which I would like to retrieve in a different column, the first date when the items were missing.  The missing date should be retrieved only in the next row of the missing date, for which I have added the comments.

 

Many thanks for your support,

Melissa

 

ItemDateComments
1454402/10/2020 
1454402/13/2020retrieve 02/11/2020 - the first date when the item was missing
1454402/14/2020 
1454402/16/2020do not retrieve 02/15/2020 - is not the first dissapearence of the item
1462202/13/2020 
1462202/15/2020retrieve 02/14/2020 - the first date when the item was missing
1462202/17/2020do not retrieve 02/16/2020 - is not the first dissapearence of the item
1462202/19/2020do not retrieve 02/18/2020 - is not the first dissapearence of the item
   
2 ACCEPTED SOLUTIONS

Hi @Anonymous ,

 

Sorry i don't quite understand what you meaning "retrieve the next day of the first occurrence".

You want each row show mindate+1?

9.PNG

Or you want show mindate+1 when an item is appearing only once?

8.PNG

If i misunderstand your meaning, please show me what's the expected out put you want.

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

Anonymous
Not applicable

Hi @Anonymous 

 

I think you might encounter some issues if it not always the second day which is missing. If so then you can tweek @v-jayw-msft 's great solution like below:

Column = 
var mindate = CALCULATE(MIN('Fact'[Date]);ALLEXCEPT('fact';'fact'[Item]))
var maxdate = MAX( TODAY(); CALCULATE(MAX('Fact'[Date]);ALLEXCEPT('fact';'fact'[Item])))

return
MINX(
    FILTER(
        ALL('Calendar');
        'Calendar'[Date] in DATESBETWEEN( 'Calendar'[Date]; mindate; maxdate) && NOT('Calendar'[Date] IN CALCULATETABLE( SELECTCOLUMNS( 'Fact'; "Date"; 'Fact'[Date]); ALLEXCEPT( 'Fact'; 'Fact'[Item])))
    );
    'Calendar'[Date]
)

 

test1.PNG

 

Kudos is highly appreciated.

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi @Anonymous 

 

I think you might encounter some issues if it not always the second day which is missing. If so then you can tweek @v-jayw-msft 's great solution like below:

Column = 
var mindate = CALCULATE(MIN('Fact'[Date]);ALLEXCEPT('fact';'fact'[Item]))
var maxdate = MAX( TODAY(); CALCULATE(MAX('Fact'[Date]);ALLEXCEPT('fact';'fact'[Item])))

return
MINX(
    FILTER(
        ALL('Calendar');
        'Calendar'[Date] in DATESBETWEEN( 'Calendar'[Date]; mindate; maxdate) && NOT('Calendar'[Date] IN CALCULATETABLE( SELECTCOLUMNS( 'Fact'; "Date"; 'Fact'[Date]); ALLEXCEPT( 'Fact'; 'Fact'[Item])))
    );
    'Calendar'[Date]
)

 

test1.PNG

 

Kudos is highly appreciated.

v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please refer the following formula.

Column = 
var mindate = CALCULATE(MIN('Table'[Date]),ALLEXCEPT('Table','Table'[Item]))
var datediff = DATEDIFF(mindate,'Table'[Date],DAY)
return
IF(datediff>1,mindate+1)

Result would be shown as below.

7.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Anonymous
Not applicable

Hi @v-jayw-msft 

 

The solution is working, but unfortunately is not capturing the scenario when an item is appearing only once. For this case, I will need to retrieve the next day of the first occurrence.

 

Many thanks,

Melisa

Hi @Anonymous ,

 

Sorry i don't quite understand what you meaning "retrieve the next day of the first occurrence".

You want each row show mindate+1?

9.PNG

Or you want show mindate+1 when an item is appearing only once?

8.PNG

If i misunderstand your meaning, please show me what's the expected out put you want.

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Anonymous
Not applicable

@v-jayw-msft 

 

The second version is what I was looking for.

 

Many many thanks,

Melisa

Anonymous
Not applicable

Hi

 

I think the below code should do it for you:

First lost date = 
MINX(
    FILTER(
        ALL('Calendar');
        AND(
            'Calendar'[DateDateTime] IN DATESBETWEEN( 'Calendar'[DateDateTime]; MIN( 'Fact'[Date]); MAX( 'Fact'[Date]));
            NOT 'Calendar'[DateDateTime] IN VALUES( 'Fact'[Date])
        )
    );
    'Calendar'[DateDateTime]
)

 

I have a calendar table with all dates and my relationship is between the date in your fact table and the DateDateTime column.

 

If this helps then please mark it as the accepted solution. 

Anonymous
Not applicable

Hi @Anonymous 

 

I have tried to replicate your solution, but in the new column I don't get any values. Can you, please, share the PBIx file to check there the solution?

 

Thank you!

Anonymous
Not applicable

Hi @Anonymous 

 

I'm writing it as a measure. Do you need it as a calculated column?

test1.PNG

Anonymous
Not applicable

Hi @Anonymous 

 

Yes, we need it in a new column.

 

Thank you!

Anonymous
Not applicable

Hi @Anonymous 

 

You can make it as a calculated table like the one below:

test1.PNG

 

The methodology is:

  • Group your fact table by item
  • Calculate the [First lost date] using the measure from the first reply.

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.