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

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

Reply
JajatiDev
Helper II
Helper II

Convert a DAX to M Query

Hi,

I need guidance on how to write the code to convert the following DAX into an M query.

 

IF('Open Orders'[Delivery Type]="Full order consolidation" && SUMX(FILTER('Open Orders ','Open Orders '[Order No] = EARLIER('Open Orders '[Order No])),'Open Orders '[Order Quantity])=SUMX(FILTER('Open Orders ','Open Orders '[Order No]=EARLIER('Open Orders '[Order No])),'Open Orders '[Confirmed Quantity]),"Allocated",

IF('Open Orders '[Delivery Type]="Full order consolidation" && SUMX(FILTER('Open Orders ','Open Orders '[Order No]=EARLIER('Open Orders '[Order No])),'Open Orders '[Confirmed Quantity])>0 ,"Partial Allocation",

"Pending Allocation"))

 

Regards,

Jajati Dev

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

Hi @JajatiDev ,

 

Please try the custom column in Power Query.

 

= let 
  no = [Order No],
  tab = Table.SelectRows(#"Changed Type", each [Order No] = no),
  sumorder = List.Sum(tab[#"Order Quantity"]),
  sumCom = List.Sum(tab[#"Confirmed Quantity"])
in
  if [Delivery Type] = "Full order consolidation" and sumorder = sumCom then "Allocated" else if  [Delivery Type]= "Full order consolidation" and sumCom >0 then "Partial Allocation" else "Pending Allocation"

vkkfmsft_0-1657507226123.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

2 REPLIES 2
wdx223_Daniel
Super User
Super User

NewStep=let a=Table.Buffer(Table.Group(PreviousStepName,"Order No",{"n",each List.Sum([Order Quantity])-List.Sum([Confirmed Quantity])})) in Table.AddColumn(PreviousStepName,"New Column",each if [Delivery Type]="Full order consolidation" and a{[#"Order No"=[Order No]]}?[n]?>0 then "Partial Allocation" else "Allocated")

v-kkf-msft
Community Support
Community Support

Hi @JajatiDev ,

 

Please try the custom column in Power Query.

 

= let 
  no = [Order No],
  tab = Table.SelectRows(#"Changed Type", each [Order No] = no),
  sumorder = List.Sum(tab[#"Order Quantity"]),
  sumCom = List.Sum(tab[#"Confirmed Quantity"])
in
  if [Delivery Type] = "Full order consolidation" and sumorder = sumCom then "Allocated" else if  [Delivery Type]= "Full order consolidation" and sumCom >0 then "Partial Allocation" else "Pending Allocation"

vkkfmsft_0-1657507226123.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
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 Kudoed Authors