cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
KDavidP1987 Regular Visitor
Regular Visitor

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

Accepted Solutions
Super User
Super User

Re: Variables in Power Query, Error Handling

Hi @KDavidP1987 ,

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.

 

 

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

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




View solution in original post

4 REPLIES 4
Super User
Super User

Re: Variables in Power Query, Error Handling

Hi @KDavidP1987 ,

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.

 

 

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

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




View solution in original post

KDavidP1987 Regular Visitor
Regular Visitor

Re: Variables in Power Query, Error Handling

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

Super User
Super User

Re: Variables in Power Query, Error Handling

Hi @KDavidP1987 ,

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.

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

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




KDavidP1987 Regular Visitor
Regular Visitor

Re: Variables in Power Query, Error Handling

@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
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)