Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
My goal is to get the value at the closest time between the Referral Date milestone and the DateTime, given some conditions I will discuss later. I have a table below that shows an example.
I created two columns in Powerbi, a Referral Milestone to DateTime and one with ABS, in case the closest time falls before the milestone.
I am struggling with my equation. I want the Final Value with the closest DateTime within 180 minutes or less after the Referral Date or anytime before the Referral Datetime. So, anything from -x to 180. Different attributes have different conditions. Another attribute, MAP, is -x to 60 minutes.
The value I need from the table above is 7.38, from the -6647 row, since that is the nearest value.
I created a Measure that seems to work, and when I plug in my filters, it returns the value I want, regarding the minumum time between the Referral Date and DateTime. It also filters the other attributes as expected.
Solved! Go to Solution.
@ARomain57 I would the following, it's a classic Lookup Min/Max pattern: Lookup Min/Max - Microsoft Fabric Community
Measure =
VAR __ID = MAX( 'Final Table'[Referral ID] )
VAR __Attribute = MAX( 'Final Table'[Attribute] )
VAR __Lowest = MINX( FILTER( ALL( 'Final Table' ), [Referral ID] = __ID && [Attribute] = __Attribute ), [Referral Milestone to DateTime ABS] )
VAR __Final = MINX( FILTER( ALL( 'Final Table' ), [Referral Milestone to DateTime ABS] = __Lowest && [Referral ID] = __ID && [Attribute] = __Attribute ), [Final Value] )
RETURN
__Final
@ARomain57 I would the following, it's a classic Lookup Min/Max pattern: Lookup Min/Max - Microsoft Fabric Community
Measure =
VAR __ID = MAX( 'Final Table'[Referral ID] )
VAR __Attribute = MAX( 'Final Table'[Attribute] )
VAR __Lowest = MINX( FILTER( ALL( 'Final Table' ), [Referral ID] = __ID && [Attribute] = __Attribute ), [Referral Milestone to DateTime ABS] )
VAR __Final = MINX( FILTER( ALL( 'Final Table' ), [Referral Milestone to DateTime ABS] = __Lowest && [Referral ID] = __ID && [Attribute] = __Attribute ), [Final Value] )
RETURN
__Final
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
78 | |
57 | |
37 | |
34 |
User | Count |
---|---|
99 | |
56 | |
56 | |
46 | |
40 |