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

Calculate using filter

i have two tables 

 

First table has a date where citations were issued.

Second table has a date where officer was on a certain schedule.

 

The tables are joined by a unique ibm # 

 

i am trying to filter the data to show what shift the officer wrote the tickets on. I can get total citations written by the officer but if that officer works on a different shift it also produces the total for that shift as a total of the officer

ibmoffense_datecitation_number
jj22001/01/2022

1

jj22001/01/2022

2

jj22001/02/2022

5

aa42001/01/2022

3

aa42001/01/20224
aa42001/02/2022

6

 

ibmshiftshift start date
jj220a shift01/01/2022
jj220a shift01/02/2022
aa420b shift01/01/2022
aa420t shift01/02/2022
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Create a calculated column on the Citation table

Shift = 
var offenseDate = Citations[Offense date]
return SELECTCOLUMNS( TOPN( 1, 
   FILTER( RELATEDTABLE( Shifts ), Shifts[Start date] <= offenseDate ),
   Shifts[Start date], DESC ),
   "@shift", Shifts[Shift]
)

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

Create a calculated column on the Citation table

Shift = 
var offenseDate = Citations[Offense date]
return SELECTCOLUMNS( TOPN( 1, 
   FILTER( RELATEDTABLE( Shifts ), Shifts[Start date] <= offenseDate ),
   Shifts[Start date], DESC ),
   "@shift", Shifts[Shift]
)
Anonymous
Not applicable

Thank you that works 

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.