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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Nese_FZ
Helper I
Helper I

How to return a columm name using DAX or M formula?

Good afternoon

I need help so solve a simple query: 

 

Consider the following scenario:

I have a table with several projects where each customer is in a row and the date of the last status according to the defined columns. I only have one date on the line, which is the client's last status. The others status are null.

 

How to create a column that returns the last customer status (column name)?

 

follow the example table ( in red the expect solution). Thanks!

 

Nese_FZ_1-1604430726771.png

 

 

2 ACCEPTED SOLUTIONS

Hi, 

Thanks for your help

I tried but my source is not an excel table (I just used it as an example). It is already a table in Power Query. I was unable to adjust the first step (source)

Could you help me?

thanks

View solution in original post

Anonymous
Not applicable

Hi @Nese_FZ ,

 

Based on your description, you can do some steps as follows.

  • Suggestion 1:

You can just unpivot the columns in Power Query.

 

v-yuaj-msft_0-1604626232655.png

Result:

v-yuaj-msft_1-1604626039761.png

 

 

  • Suggestion 2:

You can create a calculated column as follows.

actual status =

IF(

   ISBLANK('CASE1'[finish]),

   IF(

       ISBLANK('CASE1'[in treatment]),

       "return",

       "in treatment"

    ),

    "finish"

)

 

Result:

v-yuaj-msft_2-1604626039765.png

 

Hope that's what you were looking for.

 

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Nese_FZ ,

 

Based on your description, you can do some steps as follows.

  • Suggestion 1:

You can just unpivot the columns in Power Query.

 

v-yuaj-msft_0-1604626232655.png

Result:

v-yuaj-msft_1-1604626039761.png

 

 

  • Suggestion 2:

You can create a calculated column as follows.

actual status =

IF(

   ISBLANK('CASE1'[finish]),

   IF(

       ISBLANK('CASE1'[in treatment]),

       "return",

       "in treatment"

    ),

    "finish"

)

 

Result:

v-yuaj-msft_2-1604626039765.png

 

Hope that's what you were looking for.

 

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Hi, 

 

Thanks for your suggestion 2.  I tested and worked also. 

Fowmy
Super User
Super User

@Nese_FZ 

In Power Query, Paste the below on a Blank Query in the Advanced Editor and check the steps.

Only three steps, Select Project and Client > UnPivot Other Columns, Filter Value Column <> Null and remove Value column.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc9LDoAgDATQu7Am6bTy8yzEGxB33l+QoIW4aqCvTMnZxGSsYYBRK5gQSfrhvEoZ5bBK8tdkrAOTlOWZmuCJpQ80uft6J4CH7vFP+pBh7PnINUDLqD4hnrBNA1omLQPBNeleedw=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [project = _t, #"Client ID" = _t, #"in treatment" = _t, finish = _t, return = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"project", "Client ID"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] <> "null")),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Value"})
in
    #"Removed Columns"



Fowmy_0-1604432323262.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi, 

Thanks for your help

I tried but my source is not an excel table (I just used it as an example). It is already a table in Power Query. I was unable to adjust the first step (source)

Could you help me?

thanks

Hi,

 

I understood the steps and it was worked.

 

Thanks for your help

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors