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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Variables in Power Query, Error Handling

Hello,

 

Apologies for my naivete and inexperience regarding PowerQuery and DAX, in advance.  I need some help understanding something.  

 

I've reached out twice now for solutions to some computational issues I've been dealing with in automating reports through the use of PowerQuery and PowerPivot.  In both cases I received brilliant responses which included code that utilized what appeared to be variable declarations to accomplish the challenges.  I understand enough to see how they should work to solve my situations, but in both cases I receive the same error (shown below), which makes me think I'm misunderstanding something about the functionality of DAX (?) in PowerQuery.

 

VariableErrors.PNG

 

 

https://community.powerbi.com/t5/Power-Query/Linking-TimeStamp-to-Value-between-Dates-in-Seperate-Ta...

 

https://community.powerbi.com/t5/Power-Query/DateDiff-between-rows-of-Status-changes/m-p/764456#M255...

 

If someone could help me to better understand this, what I'm doing wrong or misunderstanding about coding in DAX, I would be most grateful!

 

 

Sincerely,

Kristopher

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @Anonymous ,

you cannot use DAX-code in the query editor.

Either use the DAX code in the table view of the data model and add a column there or search for some M-code to use in the query editor.

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
ImkeF
Super User
Super User

Hi @Anonymous ,

you cannot use DAX-code in the query editor.

Either use the DAX code in the table view of the data model and add a column there or search for some M-code to use in the query editor.

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Hi @ImkeF ,

 

Thank you for the prompt reply, and insight!

 

So, to make sure I understand, "DAX code" is used within PowerPivot table view, and "M-Code" is used in PowerQuery Editor.  

 

Is there any difference in processing efficiency between solutions in one or the other, assuming the problem can be solved either way.  Is M-Code generally more restrictive than DAX, capability wise?

 

Sincerely,

Kristopher

Hi @Anonymous ,

yes, you're right.

 

Performance depends. But most often, DAX is faster.

Disadvantage of a DAX-columns is that it cannot be optimized for compression in the Vertipaq engine. But that effect will most likely only be relevant in very large models.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

@ImkeF ,

 

Thank you very much for all of this information, it has been especially helpful and enlightening!!  Apologies again for my inexperience with this method of reporting/coding.

 

The dataset I am reporting from is relatively large, in comparison to previous dataset's I reported from; it covers several years of ticketing systems data.  Each primary data table contains 300K - 700K rows, appx.  I'm trying to limit the scope of data pulled to only the MVP, to retain efficiency in processing and storage.

 

Have a great remainder to your week!!

 

Sincerely,

Kristopher

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors