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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Return Column Name of Last Non-zero value in row range

Hi all - I am attempting to recreate a formulated column I have in excel to DAX language.  I have had a lot of luck googling other power bi queries, but I can't find anything on this.  I am using the lookup function in excel, but i can't find the equivalent in DAX.  Dax has a "lookupvalue" fuction but this does not seem to work the same.

The custom column needs to be populated by the "column name" corresponding to the last "non-zero" value in a row.  Example is below of the excel version of the formula.  Does anyone know how to make this same calculation with a custom DAX column in Power BI?  

 

=LOOKUP(2,1/(Table1[@[FY2021]:[FY2031]]<>0),RIGHT(Table1[[#Headers],[FY2021]:[FY2031]],4))

 

AliForrester1_0-1619366637467.png

 

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please correct me if I wrongly understood your question.

In order to create the table like above, the first step that I generally take is to transform the table like below.

 

Picture2.png

 

Then, the lookup tables are created (in general), and the relationships can be created like below.

 

Picture3.png

 

All measures for creating the below visualization are in the sample pbix file, and the link is down below.

Picture4.png

 

 

https://www.dropbox.com/s/rm9xeguaegqvpc5/ali.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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