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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
nirvana_moksh
Impactful Individual
Impactful Individual

DAX To M Query

Hey All,

 

I had a question in regards to changing the below DAX to M and if it is possible:

 

CALCULATE(LASTNONBLANK('Table A'[Column 1],1),FILTER('Table A','Table A'[Index] = MIN('Table A'[Index])))

 

 

The above DAX basically finds the latest COLUMN 1 value using the Index column I have set up, I want to do this in M query so that I can limit data from right there instead of using the above DAX.

 

 

Thank You

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @nirvana_moksh

As tested, I add an index column from 1.

Code in Advanced Editor

let

    Source = Excel.Workbook(File.Contents("C:\Users\maggiel\Desktop\PR4.0\5\5.29\Circular dependancy.xlsx"), null, true),

    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],

    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),

    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"taskId", Int64.Type}, {"startupGoalDate", type date}, {"duration", Int64.Type}}),

    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),

    #"Added Conditional Column1" = Table.AddColumn(#"Added Index", "min", each List.Min(Table.Column(#"Added Index","Index"))),

    #"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1","Custom", each if [Index]=[min]  then List.Last(Table.Column(#"Added Index","duration")) else null) 

in

#"Added Conditional Column2"

 

Something easier to do with DAX maybe complex with M query,

Reference:

List.Last

Table.SelectRows

Table.SelectColumns

 

Best Regards

Maggie

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @nirvana_moksh

As tested, I add an index column from 1.

Code in Advanced Editor

let

    Source = Excel.Workbook(File.Contents("C:\Users\maggiel\Desktop\PR4.0\5\5.29\Circular dependancy.xlsx"), null, true),

    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],

    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),

    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"taskId", Int64.Type}, {"startupGoalDate", type date}, {"duration", Int64.Type}}),

    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),

    #"Added Conditional Column1" = Table.AddColumn(#"Added Index", "min", each List.Min(Table.Column(#"Added Index","Index"))),

    #"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1","Custom", each if [Index]=[min]  then List.Last(Table.Column(#"Added Index","duration")) else null) 

in

#"Added Conditional Column2"

 

Something easier to do with DAX maybe complex with M query,

Reference:

List.Last

Table.SelectRows

Table.SelectColumns

 

Best Regards

Maggie

Thank you, I will try this out and check the output

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.