March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi, 1st time poster here, hope this makes sense.
I need to retreive column "Current Risk Level" from table "RM_ImpactHistory" but with multiple conditions in place:
1. Find the max date but less than or equal to selectedDateTime, this is a variable coming from a slicer using selectedvalue
2. Risk ID being the same between these two tables: RM_ImpactAnalysisImpact and RM_ImpactHistory
Here is my current formula:
Here's a picture of the corresponding data table
When 10/4/2024 4:23:33 PM is selected in the slicer, the expected result for "current risk level" should be "Medium: 12" and that is working. But when 11/6/2024 12:47:49 PM is selected in the slicer, the expected result for "current risk level" should be "Low: 8" and that is not working, it continues to show Medium: 12.
Solved! Go to Solution.
Hi @stewartad1
Please try this:
CurrRiskLevel =
VAR _MaxDate =
MAXX (
FILTER (
ALLSELECTED ( RM_ImpactHistory ),
RM_ImpactHistory[RiskID] = RM_ImpactAnalysisImpact[RiskID]
&& RM_ImpactHistory[RM_History.EventDate] <= [SelectedDateTime]
),
RM_ImpactHistory[RM_History.EventDate]
)
RETURN
CALCULATE (
SELECTEDVALUE ( RM_ImpactHistory[Current Risk Level] ),
FILTER (
ALLSELECTED ( RM_ImpactHistory ),
RM_ImpactHistory[RM_History.EventDate] = _MaxDate
)
)
Don't use aggregate functions to process text-type data, the result of the MAX(RM_ImpactHistory[Current Risk Level]) is Medium: 12 but Low: 8 because the initial M is in front of L.
Hope it can help,
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @stewartad1
Please try this:
CurrRiskLevel =
VAR _MaxDate =
MAXX (
FILTER (
ALLSELECTED ( RM_ImpactHistory ),
RM_ImpactHistory[RiskID] = RM_ImpactAnalysisImpact[RiskID]
&& RM_ImpactHistory[RM_History.EventDate] <= [SelectedDateTime]
),
RM_ImpactHistory[RM_History.EventDate]
)
RETURN
CALCULATE (
SELECTEDVALUE ( RM_ImpactHistory[Current Risk Level] ),
FILTER (
ALLSELECTED ( RM_ImpactHistory ),
RM_ImpactHistory[RM_History.EventDate] = _MaxDate
)
)
Don't use aggregate functions to process text-type data, the result of the MAX(RM_ImpactHistory[Current Risk Level]) is Medium: 12 but Low: 8 because the initial M is in front of L.
Hope it can help,
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, that worked, thank you so much!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
18 | |
15 | |
9 | |
7 |
User | Count |
---|---|
37 | |
32 | |
16 | |
16 | |
12 |