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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Michael_DOC
Regular Visitor

Return nonblank value issues.

Below is my Dax formula: 

 

Medical Score =

VAR ClosestRow =
    CALCULATE (
        FIRSTNONBLANK(SCORES[SCOR_MEDICAL], 1),  
        FILTER (
            SCORES,
            SCORES[SCOR_PER_ID] = PS[Number] &&  
            ABS(DATEDIFF(PS[OffenseDt], SCORES[SCOR_EFF_DATE], DAY)) =
            MINX (
                FILTER (
                    SCORES,
                    SCORES[SCOR_PER_ID] = PS[Number]
                ),
                ABS(DATEDIFF(PS[OffenseDt], SCORES[SCOR_EFF_DATE], DAY))
            )
        )
    )
RETURN
    ClosestRow
 
I want the formula to make ID1 = ID2 without creating a relationship (many to many) and Return ValueB (SCORES[SCOR_MEDICAL])  for DateA (PS[OffenseDt]) is closest to DateB (SCORES[SCOR_EFF_DATE]) . If ValueB is blank, return the next Value in the column. The above Dax formula works 99% but I am still getting a few blank values based on my data. 
 
How do I have my formula skip blanks and return the next whole number value without removing empties from my table? 
 
1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @Michael_DOC - you can modify the logic to filter out blank values in the FIRSTNONBLANK part of your measure. 

ceck the below measure:

Medical Score =
VAR ClosestRow =
CALCULATE (
FIRSTNONBLANK(
SCORES[SCOR_MEDICAL],
NOT (ISBLANK(SCORES[SCOR_MEDICAL])) // Exclude blank values
),
FILTER (
SCORES,
SCORES[SCOR_PER_ID] = PS[Number] &&
ABS(DATEDIFF(PS[OffenseDt], SCORES[SCOR_EFF_DATE], DAY)) =
MINX (
FILTER (
SCORES,
SCORES[SCOR_PER_ID] = PS[Number] &&
NOT (ISBLANK(SCORES[SCOR_MEDICAL])) // Exclude blank values in comparison
),
ABS(DATEDIFF(PS[OffenseDt], SCORES[SCOR_EFF_DATE], DAY))
)
)
)
RETURN
ClosestRow

 

Hope it works 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
rajendraongole1
Super User
Super User

Hi @Michael_DOC - you can modify the logic to filter out blank values in the FIRSTNONBLANK part of your measure. 

ceck the below measure:

Medical Score =
VAR ClosestRow =
CALCULATE (
FIRSTNONBLANK(
SCORES[SCOR_MEDICAL],
NOT (ISBLANK(SCORES[SCOR_MEDICAL])) // Exclude blank values
),
FILTER (
SCORES,
SCORES[SCOR_PER_ID] = PS[Number] &&
ABS(DATEDIFF(PS[OffenseDt], SCORES[SCOR_EFF_DATE], DAY)) =
MINX (
FILTER (
SCORES,
SCORES[SCOR_PER_ID] = PS[Number] &&
NOT (ISBLANK(SCORES[SCOR_MEDICAL])) // Exclude blank values in comparison
),
ABS(DATEDIFF(PS[OffenseDt], SCORES[SCOR_EFF_DATE], DAY))
)
)
)
RETURN
ClosestRow

 

Hope it works 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors