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

Join 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.

Reply
Jebilaya
Helper III
Helper III

FIRSTNONBLANK returning blank with additional filter

I have a measure that is calculating closest store location to a customers address.  There are 2 types of order a customer can place so only some stores are able to take a "Heavy" order.

The DAX works fine if I don't apply the addditional filter:  filter('Fact FBS Store Lats Longs', 'Fact FBS Store Lats Longs'[Offer] = "Heavy") and there are no blanks returned.

However with the additional filter in some values (about 1 / 4) are returned as blank with no obvious pattern.  

 

This Dax returns some blank values (not good)

CALCULATE (
        FIRSTNONBLANK( 'Fact FBS Store Lats Longs'[Store Name], 0),
        // Arbitrary tie-break
      filter('Fact FBS Store Lats Longs', 'Fact FBS Store Lats Longs'[Offer] = "Heavy"),
        TOPN (1
            ,
            'Fact FBS Store Lats Longs',
            VAR Lat2 = 'Fact FBS Store Lats Longs'[Latitude]
            VAR Lng2 = 'Fact FBS Store Lats Longs'[Longitude]
            //---- Algorithm here -----
            VAR A =
                0.5 - COS ( ( Lat2 - Lat1 ) * P ) / 2
                    + COS ( Lat1 * P ) * COS ( lat2 * P ) * ( 1 - COS ( ( Lng2 - Lng1 ) * P ) ) / 2
            VAR final =
                12742 * ASIN ( ( SQRT ( A ) ) )
            RETURN
                final,
            ASC
        )
    )
 
This DAX returns no blank values (good)
 
FIRSTNONBLANK ( 'Fact FBS Store Lats Longs'[Store Name], 0),
        // Arbitrary tie-break
        TOPN (
            1,
            'Fact FBS Store Lats Longs',
            VAR Lat2 = 'Fact FBS Store Lats Longs'[Latitude]
            VAR Lng2 = 'Fact FBS Store Lats Longs'[Longitude]
            //---- Algorithm here -----
            VAR A =
                0.5 - COS ( ( Lat2 - Lat1 ) * P ) / 2
                    + COS ( Lat1 * P ) * COS ( lat2 * P ) * ( 1 - COS ( ( Lng2 - Lng1 ) * P ) ) / 2
            VAR final =
                12742 * ASIN ( ( SQRT ( A ) ) )
            RETURN
                final,
            ASC
        ))
0 REPLIES 0

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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