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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
jaysoulz
Helper I
Helper I

USERELATIONSHIP with FILTER

Hi,

I am trying to display the correct timing from my worker and I am having the issue where I need two dates (one for Start Time ; Stop Time).

Calendar [Date] is linked to DATA [StartDate] (active) and DATA [StopDate] (inactive)



Picture2.png

Start time is showing correctly as it is the same date as the Slicer:

Picture4.png
 
However, I am seeing a blank when I tried to input the USERELATIONSHIP for the Stop Time:

StopDateTime =
CALCULATE(
    MAX(DATA[StopDateTime]),
    FILTER(
        DATA,
        HOUR(DATA[StopDateTime]) < 12
    ),
    USERELATIONSHIP(DATA[StopDate], 'Calendar'[Date])
)

Result:
jaysoulz_2-1707129462565.png

 

In order to make it works, I need Start Time as Nov 13 (as slicer - MIN from PM) and Stop Time Nov 14 (MAX from AM).

 
Expected result:
jaysoulz_0-1707129538072.png

Anyone know how to?

 
Thanks
6 REPLIES 6
Daniel29195
Super User
Super User

@jaysoulz 

 

StopDateTime =
CALCULATE(
    MAX(DATA[StopDateTime]),
    FILTER(
        all(DATA),
        HOUR(DATA[StopDateTime]) < 12
    ),
    USERELATIONSHIP(DATA[StopDate], 'Calendar'[Date])
)

 

 

let me know if this works for you . 

Nope. All results are 2023-12-31 11:56:51AM. The result date doesnt match the Punch Out date...

Anonymous
Not applicable

Hi @jaysoulz ,

The DAX formula you provided seems almost correct, but I would suggest a slight modification:

StopDateTime =
CALCULATE(
    MAX(DATA[StopDateTime]),
    USERELATIONSHIP(DATA[StopDate], 'Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Date] <= MAX('Calendar'[Date])
    ),
    HOUR(DATA[StopDateTime]) < 12
)

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

I change your DAX into

 

StopDateTimeRon = 
CALCULATE(
    MAX(REPORT[StopDateTime]),
    USERELATIONSHIP(REPORT[StopDate], 'Calendar'[Date]),
    FILTER(
        ALL('Calendar'),
        'Calendar'[Date] <= MAX(REPORT[StopDateTime])
    ),
    HOUR(REPORT[StopDateTime]) < 12
)

 

However, it does not provide all the correct time:
Picture4.png

Thanks for the help!

amitchandak
Super User
Super User

@jaysoulz , Try like

 

StopDateTime =
CALCULATE(CALCULATE(
MAX(DATA[StopDateTime]),USERELATIONSHIP(DATA[StopDate], 'Calendar'[Date]))
FILTER(
DATA,
HOUR(DATA[StopDateTime]) < 12
)

)

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

It does not seem to work:


Picture9.png

Thanks for helping!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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