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
umasankar
Frequent Visitor

Need help to convert DAX to M Code

Hi,

 

I am having a requiremnet to fulfill the client request. For this i need to create a calculated mesures later need to pivot those measures. below is the calculated measure.

TotalDef = CALCULATE(SUM('SAP Feed'[Quantity]),FILTER('SAP Feed',('SAP Feed'[Account (Planning) (Text)]="Def - Export Planned" || 'SAP Feed'[Account (Planning) (Text)]="Def - Export UnPlanned")))
 
Like the above we need to craete another 2 measures and after that need to pivot these three. Pivot is only available in power Query right. so i want convert those DAX measures to calculated column in M query.
 
cananyone help me please. 

 

4 REPLIES 4
umasankar
Frequent Visitor

Hi Everyone,

 

Thanks for all your replies. As of now i received the conformation that it is not possible for my scenario. So i am giving alternative solution to the client.

Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected end result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-chenwuz-msft
Community Support
Community Support

Hi @umasankar ,

 

You can first filter the table and use groupby in power query edit.

vchenwuzmsft_1-1644807897349.pngvchenwuzmsft_2-1644807984685.png

This the code you can refer:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSjQwMFTSUXJJTVPQVXCtKMgvKlEIyEnMy0tNAQobKsXqEFJjhFNNaB5ClTFRqkyIUmWKrMq/JCO1CEibwQSNcDvVnAg1FjjVIDvBkihVhgbEKTNEVgbzkCEwYGMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, #"Account (Planning) (Text)" = _t, Quantity = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Account (Planning) (Text)", type text}, {"Quantity", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([#"Account (Planning) (Text)"] <> "Other")),
    #"Pivoted Column" = Table.Pivot(#"Filtered Rows", List.Distinct(#"Filtered Rows"[#"Account (Planning) (Text)"]), "Account (Planning) (Text)", "Quantity", List.Sum)
in
    #"Pivoted Column"

 

Best Regards

Community Support Team _ chenwu zhu

 

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

BA_Pete
Super User
Super User

Hi @umasankar ,

 

Not sure if I've fully understood your requirements here, but if you want to 'pivot' or display data in different formats, you can just use the matrix or table visual.

BA_Pete_0-1644415898776.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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