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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
PompanoPete
Frequent Visitor

measure to return Latest value for each employee

I have a fact table with events, a date table, and a person table.  I am trying to write a measure that returns the most recent event for each employee.  Having trouble, any help appreciated.  Below is what I have started..

_most recent Event =
CALCULATE (
    MAX ( vFactEmployeeEvent[Event Name] ),
    FILTER (
        ALL ( vFactEmployeeEvent ),
        'Date'[Full Date] = MAX ( 'Date'[Full Date] ),
        'Person'[Employee Number] = 'Person'[Employee Number]
    )
)

 

 

4 REPLIES 4
FreemanZ
Super User
Super User

hi @PompanoPete ,

 

try to plot a table visual with 'Person'[Employee Number] column, 'Date'[Full Date]  column and a measure like:
 
_most recent Event =
CALCULATE (
    MAX ( vFactEmployeeEvent[Event Name] ),
    FILTER (
        ALL ( vFactEmployeeEvent ),
        'Date'[Full Date] <= MAX ( 'Date'[Full Date] )&& 'Person'[Employee Number] = MAX('Person'[Employee Number])
    )
)
Dangar332
Super User
Super User

Hi, @PompanoPete 

try below

_most recent Event =
var a = calculate(max('Date'[Full Date]),allexcept('Person','Person'[Employee Number]))
CALCULATE (
    MAX ( vFactEmployeeEvent[Event Name] ),
    FILTER (
        ALL ( vFactEmployeeEvent ),
        'Date'[Full Date] = a,
        'Person'[Employee Number] = 'Person'[Employee Number]
    )
)

I added a return before calculate.  Here is the latest.

PompanoPete_0-1698936945339.png

getting error stating cannot find ful Date..  I seem to get this allot and tried using related but no luck.

I tried returning just the variable a, which evaluated without error, but instead of getting the max date, I just got full date and the number of rows for Employee1 jumped from 11 to hundreds.  I suspect one for each row in the fact table.  Thanks for the response.  Below is sample data.

Result.PNG

 

_most recent Event =
var a = calculate(max('Date'[Full Date]),allexcept('Person','Person'[Employee Number]))
CALCULATE (
    MAX ( vFactEmployeeEvent[Event Name] ),
    FILTER (
        ALL ( vFactEmployeeEvent ),
        'Date'[Full Date] = a &&
        'Person'[Employee Number] = 'Person'[Employee Number]
    )
)

 

Hi, @PompanoPete 

replace ( , ) with &&

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.