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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Nicole_H
Frequent Visitor

Dax to Power Query

I've spent way too long on this, and can't get it to work.  Can anyone covert this Dax into PowerQuery please?  I am not sure if it can be done.

 

The DAX code repeats [Extract_Measure] for each ID

NewMeasure
var form_id = 'Table'[ID]

RETURN
MAXX(
FILTER(
ALL('Table'),
'Table'[ID] = form_id
&& 'Table'[Answer] = 'Table'[Extract_Measure]
),
'Table'[Extract_Measure]
)

1 ACCEPTED SOLUTION
aduguid
Super User
Super User

I updated my answer, hope this works for you 

 

let
    Source = TableName,
    GroupedTable = Table.Group(Source, {"ID"}, {
        {"NewMeasure", each 
            let
                form_id = Table.FirstN(_, 1){0}[ID],
                FilteredTable = Table.SelectRows(Source, each [ID] = form_id and [Answer] = _[Extract_Measure]{0}),
                MaxValue = List.Max(FilteredTable[Extract_Measure])
            in
                MaxValue
        }
    })
in
    GroupedTable

 

View solution in original post

8 REPLIES 8
Nicole_H
Frequent Visitor

Thanks all, I did eventually get aduguid's solution to work

v-jingzhan-msft
Community Support
Community Support

Hi @Nicole_H 

 

Please check if my approach below meets your need. 

Firstly I have data like:

vjingzhanmsft_2-1721022185730.png

Add a custom step in the Formula bar directly with below code. Replace #"Changed Type" with your previous step name. 

= Table.Group(#"Changed Type", {"ID"}, {{"All", each _, type table [ID=nullable text, Answer=nullable number, Extract_Measure=nullable number]}, {"Filter", each List.Max(Table.Column(Table.SelectRows(_, each [Answer] = [Extract_Measure]), "Extract_Measure"))}})

vjingzhanmsft_0-1721022139201.png

Expand "All" column in the previous result. Then you will have below result. "Filter" column is the new column we want. 

vjingzhanmsft_1-1721022173826.png

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

ronrsnfld
Super User
Super User

Please provide some usable data (as text, not a screenshot) along with what you expect for results from that data, and the logic required to go from Source data to Results.

Sorry ronrsnfld, I'm using really sensitive data, which is why I gave a vague example, but if the other solutions don't work I'll try and attach something.  Thanks

Hi @Nicole_H 

Have you resolved this issue? If any of the answers provided were helpful, please consider accepting them as a solution. If you have found other solutions, we would greatly appreciate it if you could share them with us. Thank you!

 

Best Regards,
Jing

If you do, use made up data that reproduces your problem. Don't use real data.

aduguid
Super User
Super User

I updated my answer, hope this works for you 

 

let
    Source = TableName,
    GroupedTable = Table.Group(Source, {"ID"}, {
        {"NewMeasure", each 
            let
                form_id = Table.FirstN(_, 1){0}[ID],
                FilteredTable = Table.SelectRows(Source, each [ID] = form_id and [Answer] = _[Extract_Measure]{0}),
                MaxValue = List.Max(FilteredTable[Extract_Measure])
            in
                MaxValue
        }
    })
in
    GroupedTable

 

Thanks for your speedy reply!  Although I don't get a syntax error the new column is returning Error, not sure what I have done wrong (or what I'm doing at all to be honest!)

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors