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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Andregewehr
Helper I
Helper I

Add new column with next non blank value

Hi everyone, 

 

I have this table:

01r.JPG

 

I want to add a new column filling the blank values with the next value for each SKU (A, B and C) and the next date. I tried this DAX formula:

 

FIRSTNONBLANK = IF(ISBLANK('Table'[Stock]) || 'Table'[Stock] = "",
CALCULATE(
FIRSTNONBLANK('Table'[Stock], TRUE()),
FILTER('Table',
'Table'[SKU] = EARLIER('Table'[SKU]) && 'Table'[Date] <= EARLIER('Table'[Date]) && 'Table'[Stock] <> "")
),
[Stock]
)
 
These are the expected values for each SKU (A, B and C) and the FIRSTNONBLANK errors I put in red. All the values for B and C are zero. Where is my mistake? 😥
A.jpgB.jpgC.jpg
 
 
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Andregewehr 

try like:

Column =
    MAXX(
        TOPN(
             1,
             FILTER(
                'Table',
                'Table'[SKU] = EARLIER('Table'[SKU]) && 'Table'[Date] <= EARLIER('Table'[Date]) && 'Table'[Stock] <>BLANK()
              ),
              'Table'[Date]
         ),
         'Table'[Stock]
    )

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @Andregewehr 

try like:

Column =
    MAXX(
        TOPN(
             1,
             FILTER(
                'Table',
                'Table'[SKU] = EARLIER('Table'[SKU]) && 'Table'[Date] <= EARLIER('Table'[Date]) && 'Table'[Stock] <>BLANK()
              ),
              'Table'[Date]
         ),
         'Table'[Stock]
    )

Oh my god, that was perfect! Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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