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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
PBI5851
Helper V
Helper V

DateDiff with Filter based on specific value

Hello,

 I am trying to capture the number of accounts and how long have they been in a specific status. Since we cant use a filter within datediff , not sure how to achieve this. 

AccountIDStatusSubstatusStatusDateCurrentFlag
A1001OpenFile5/1/20200
A1001OpenProgress5/2/20200
A1001CapProgress5/10/20200
A1001ShipCarrier8/1/20200
A1001ShipDelivered8/5/20201
A1004OpenFile7/8/20200
A1004ShipCarrier9/1/20200
A1004ShipDelivered9/5/20201
A1007OpenFile8/15/20200
A1007ShipCarrier9/1/20200
A1007ShipDelivered9/3/20200
A1007ShipReturned9/5/20200
A1007ShipCancelled9/10/20201

 

Primary criteria is for currentflag = 1 and Status = Ship and Substatus = Delivered, how many days has it been since today. 

 

1) Need to display the AccountID and the days it has been since above criteria (this is on the detail page)

2) A Count of Accounts where the days since above criteria has been more than 10 days (this will be in a summary page)

 

Any recommendations on how to achieve this please. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello @PBI5851

1)

DaysSinceDelivered = 
var _DelDate = CALCULATE(max(Table2[StatusDate]), FILTER(ALLEXCEPT(Table2,Table2[AccountID]),Table2[CurrentFlag] = "1" && Table2[Status] = "Ship" && Table2[Substatus] = "Delivered"))
Return DATEDIFF(_DelDate,TODAY(),DAY)

pranit828_0-1599969070949.png

2)

Delivered Morethan10Days = 
CALCULATE(COUNTROWS(Table2), FILTER(ALLEXCEPT(Table2,Table2[AccountID]),Table2[CurrentFlag] = "1" && Table2[Status] = "Ship" && Table2[Substatus] = "Delivered" && DATEDIFF(Table2[StatusDate],TODAY(),DAY)>10))

pranit828_0-1599970141709.png

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hello @PBI5851

1)

DaysSinceDelivered = 
var _DelDate = CALCULATE(max(Table2[StatusDate]), FILTER(ALLEXCEPT(Table2,Table2[AccountID]),Table2[CurrentFlag] = "1" && Table2[Status] = "Ship" && Table2[Substatus] = "Delivered"))
Return DATEDIFF(_DelDate,TODAY(),DAY)

pranit828_0-1599969070949.png

2)

Delivered Morethan10Days = 
CALCULATE(COUNTROWS(Table2), FILTER(ALLEXCEPT(Table2,Table2[AccountID]),Table2[CurrentFlag] = "1" && Table2[Status] = "Ship" && Table2[Substatus] = "Delivered" && DATEDIFF(Table2[StatusDate],TODAY(),DAY)>10))

pranit828_0-1599970141709.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.