Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Given that I have 2 tables A and B related by the CCID, how can I get the first nonblank value from a sorted table B as a calculated column? Table B is sorted using a ranked Status that determines which value would be the result value of the calculated column.
I'm unsure if LOOKUPVALUE() recognizes the sort order of the values.
For example in the table below, the ones in bold face should be the value of the calculated column:
| CCID | DocumentType | Status | StatusRank | |||
| 1000117 | Doctype 1 | 06/14/2023 | 5 | |||
| 1000117 | Doctype 1 | Rejected | 6 | |||
| 1000117 | Doctype 2 | 06/18/2023 | 5 | |||
| 1000117 | Doctype 3 | Uploaded | 1 | |||
| 1000117 | Doctype 3 | Approved | 4 | |||
| 1000117 | Doctype 4 | Approved | 4 | |||
| 1000117 | Doctype 4 | Rejected | 5 | |||
| 1000117 | Doctype 5 | Uploaded | 1 | |||
| 1000117 | Doctype 6 | Uploaded | 1 | |||
| 1000117 | Doctype 6 | Rejected | 5 | |||
| 1000117 | Doctype 7 | Uploaded | 1 |
Edit: Was able to achieve this by adding a grouped Index column in the Table B query and using FIRSTNONBLANK filtering the Table B data to only show the row with the Index = 1, but is there a better solution to this?
Correct, LOOKUPVALUE just grabs whatever it finds first. In general there is no such thing as a sort order in Power BI. You need to enforce that in your DAX query, via TOPN(1,...) or ORDER BY for example. And you will have to pay the performance penalty price.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 33 | |
| 29 | |
| 24 |
| User | Count |
|---|---|
| 127 | |
| 115 | |
| 87 | |
| 70 | |
| 69 |