Home » DAX » DAX – FIRSTNONBLANK

DAX – FIRSTNONBLANK

FIRSTNONBLANKDAX-Example

The FIRSTNONBLANK DAX function is used to returns the first value in the column for which the expression has a non blank value. This function comes under Time Intelligence DAX functions category.

Syntax

FIRSTNONBLANK(<column>,<expression>)
S no. Parameter Description
1 Column The source values.
2 Expression The expression to be evaluated for each value.




Let’s start with an example step by step-

Step-1:  Dataset as mentioned below & our Dataset name is FNBDAX.

First Non Blank Dataset

First Non Blank Dataset

Step-2: Create one measure for Sum of Total Sales.

Tot sales = SUM(FNBDAX[Sales])





Step-3: Now create measure to get first non blank date according to Sale.

FNB_Date = FIRSTNONBLANK(FNBDAX[Date],[Tot sales])

Step-4: To see measure output take one card visual from Visualization pane & drag measure to over it.

DAX Measure Output

DAX Measure Output




To get the first non blank value, Power BI DAX engine sort the data in backend then returns the value, to check this – sort table data date wise ascending order. After sort you will see first non blank date is 2018-01-05.

FirstNonBalank Date DAX

FirstNonBalankDax_1




Step-5: According to above Screen shot First Non Blank Month according to Salary is JAN. But practically this is not correct , as I told Power BI sort data according to column.

So if you will sort month column, then you will get FAB is first non Blank month, let’s understand-Measure for first non blank month according to salary-

FNB_Month = FIRSTNONBLANK(FNBDAX[Month],[Tot sales])
FirstNONBlank DAX Output

FirstNONBlank DAX Output

FirstNonBlank DAX example

FirstNonBlank DAX example

Similar DAX: LASTNONBLANK

Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.



Leave a Reply