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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.