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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ashwini12
Employee
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])

@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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors