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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors