Forum Discussion
Help with FIRSTNONBLANK
Here is the forumla for a new column:
CALCULATE(FIRSTNONBLANK('HEADCOUNT'[Location],TRUE()),Filter('HEADCOUNT','HEADCOUNT'[Unique Employee Number]='TERMINATIONS'[UEN]))
- The idea is to populate the Location from Headcount onto Terminations.
- I need to populate it from the row with the LATEST Headcount data, which is appended to the database monthly.
I sorted the Headcount table Descending according to the run date, both in the Query editor and the Table view. - It's not pulling the first non blank row - as if it is ignoring the sorting, or the Filter Expression in Calculate amends it.
Does anyone know what is going on here?
Hi Anonymous
As tested, just as you said,it is ignoring the sorting.
We should know that FirstNonBlank is like using a MIN function and will return the lowest value rather than the first item in a sequence.
Per your requirement, you want to get the the first not blank Location value for each Unique Employee Number based on the run date in Descending order in table Headcount, then put the value in the table Terminations.
As i tested, here is a workaround without using FirstNonBlank.
calculated column in table Headcount
firstnoblank =
CALCULATE (
LASTNONBLANK ( HEADCOUNT[Location], TRUE () ),
ALLEXCEPT ( HEADCOUNT, HEADCOUNT[Unique Employee Number] )
)column created in table Terminations Column = LOOKUPVALUE(HEADCOUNT[firstnoblank],HEADCOUNT[Unique Employee Number],ERMINATIONS[UEN])
Best Reagrds
Maggie
2 Replies
- v-juanli-msftCommunity Support
Hi Anonymous
As tested, just as you said,it is ignoring the sorting.
We should know that FirstNonBlank is like using a MIN function and will return the lowest value rather than the first item in a sequence.
Per your requirement, you want to get the the first not blank Location value for each Unique Employee Number based on the run date in Descending order in table Headcount, then put the value in the table Terminations.
As i tested, here is a workaround without using FirstNonBlank.
calculated column in table Headcount
firstnoblank =
CALCULATE (
LASTNONBLANK ( HEADCOUNT[Location], TRUE () ),
ALLEXCEPT ( HEADCOUNT, HEADCOUNT[Unique Employee Number] )
)column created in table Terminations Column = LOOKUPVALUE(HEADCOUNT[firstnoblank],HEADCOUNT[Unique Employee Number],ERMINATIONS[UEN])
Best Reagrds
Maggie
- Greg_DecklerCommunity Champion
Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Sample data would help tremendously, there is very little context here to go on.