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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
ashwini12
Microsoft Employee
Microsoft Employee

Hi All, I want to count the latest dates before slicer selected date dynamically with table filters.

Aim : To count previous open ticket - We want to count all distinct ticket ID having dates before slicer selected date (such that we only take the latest Auditcreated date of Ticket ID before slicerselected date) with below filters

Status column - should not be closed or removed
IsActive column should be - true
AuditCreatedDate - should be before slicer selected date
CreatedDate -    should be before slicer selected date

 

IMP : We should only consider latest AuditCreatedDate "before slicer selected date". 

Note: I have created measure for date before slicer selected date as

End Of Previous Period = [FirstSelectedDate] - 1 and start date is static as
Start Of Previous Period = DATE(2021, 1, 1)
So we should consider all the dates between  [Start Of Previous Period] and [End Of Previous Period].
 

Explanation:

Consider below 1st scenario:

slicer - 13 june to 12 july


ID  AuditCreatedDate  Status    IsActive
1     12 June                 open        True ----- max(+1)
1     11 June                 close        True
1     10 June                 close        True
2     11 June                 open        True ----- max (+1)
2     10 June                 open        True
2      9 June                   close       True
3      7 June                   close       False
3      6 June                   open       True


Ans: Previous Open ticket count = 2
------------------------------------------------------------------------------------------

Consider below 2nd scenario:

slicer - 12 june to 12 july


ID  AuditCreatedDate Status IsActive
1     12 June                 open    True  {should not consider this record as AuditedCreatedDate should be before 12 June }
1     11 June                 open     True ---- max (+1)
1     10 June                 close     True
2     11 June                 close     True         {should not consider this record as status is close}
2      10 June                open     True
2      9 June                  close     False
3      13June                 open     True {should not consider this record as AuditedCreatedDate should be before 12 June }

3      10 June                open     True -- ---max(+1)
3      6 June                  open     False


Ans: Previous Open ticket count = 2

[Previous Open Tickets] =
CALCULATE(DISTINCTCOUNT('View_AllHelpToolRequestsWithAudit (2)'[Id]),
'View_AllHelpToolRequestsWithAudit (2)'[AuditNewStatusId] <> 3 || 'View_AllHelpToolRequestsWithAudit (2)'[AuditNewStatusId] <> 4 ,
'View_AllHelpToolRequestsWithAudit (2)'[AuditIsActive] = TRUE(),
DATESBETWEEN(
('View_AllHelpToolRequestsWithAudit (2)'[AuditCreatedDate]),[Start Of Previous Period],[End Of Previous Period]),
DATESBETWEEN((Dim_Date[Date]),[Start Of Previous Period],[End Of Previous Period])
)
We have to give latest AuditCreated date between these two date ranges.
2 REPLIES 2
amitchandak
Super User
Super User

@ashwini12 , Try a measure like


measure =
var _max = maxx(filter(allselected(Table), [ID] = max(Table[ID])), [AuditCreatedDate])
var _1 = maxx(allselected(Date), Date[Date])
return
countx(filter(values(Table[ID]),_max <= _1), [ID])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak The solution provided by you gives maximum date in the entire table, requirement is different.
In the below measure we want to give only latest AuditCreated dates per ID between date range [Start Of Previous Period] and [End Of Previous Period].

Previous Open Tickets] =
CALCULATE(DISTINCTCOUNT('View_AllHelpToolRequestsWithAudit (2)'[Id]),
'View_AllHelpToolRequestsWithAudit (2)'[AuditNewStatusId] <> 3 || 'View_AllHelpToolRequestsWithAudit (2)'[AuditNewStatusId] <> 4 ,
'View_AllHelpToolRequestsWithAudit (2)'[AuditIsActive] = TRUE(),
DATESBETWEEN(
('View_AllHelpToolRequestsWithAudit (2)'[AuditCreatedDate]),[Start Of Previous Period],[End Of Previous Period]),
DATESBETWEEN((Dim_Date[Date]),[Start Of Previous Period],[End Of Previous Period])
)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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