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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Code this DAX formula in M

Hello,

I would like to code this DAX formula in Power Query M ? What is the solution please ?

Lat =
var Notif='TASK'[Notification]
var Task_Number='TASK'[Task number]
var Task_Number_Suivant=CALCULATE(MIN('TASK'[Task number]), FILTER('TASK', Notif='TASK'[Notification] && Task_Number<'TASK'[Task number]))
var lat=CALCULATE(MAX('TASK'[Latitude]), FILTER('TASK', Notif='TASK'[Notification] && Task_Number_Suivant='TASK'[Task number]))
return lat
 
Thank you !
5 REPLIES 5
wdx223_Daniel
Super User
Super User

let

Source=TASK,

Custom1=let a=Table.Group(Source,"Notification",{"n",each Table.Sort(_,"Task number"){0}[Latitude]}) in Table.AddColumn(Source,"lat",each a{[Notification=[Notification]]}[n])

in

Custom1

Anonymous
Not applicable

Hello, thank you for your help. It says "Expression.Error: A cyclic reference was encountered during evaluation."

let

Source=TASK,

Custom1=Table.FromRecords(List.Accumulate(Table.ToRecords(Table.Sort(Source,{"Notification","Task number"})),{{},"",0},(x,y)=>if x{1}=y[Notification] then {x{0}&{y&[lat=x{2}]]},x{1},x{2}} else {x{0}&{y&[lat=y[Latitude]]},y[Notification],y[Latitude]}){0})

in

Custom1

Anonymous
Not applicable

Hi @Anonymous ,

Please create a custom column.

= 
let
a = Table.SelectRows(PreviousStepName,(x)=>x[Notification]=[Notification] and x[Task number]>[Task number]),
b = List.Min(a[Task number]),
c = List.Max(Table.SelectRows(a,(y)=>y[Task number]=b)[Latitude])
in 
c

vcgaomsft_1-1682561516513.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Anonymous
Not applicable

Thank you very much for your help, it works but it takes a lot of time to load, to you have another solution for large dataset please ?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors