Tag Archives: Variables

Power Query M Primer (Part 4): Variables & Identifiers

, , , ,

Up until now, we’ve used variables without talking much about their specifics. Since we’re operating under the assumption that you have at least a little experience with another programming or scripting language, how we’ve used variables has probably made sense.

However, there might be differences—perhaps even significant differences—between how variables work in other languages you’ve used with and how they behave in the Power Query M language. Let’s spend some time exploring variables and related concepts to clear up any lurking confusion and position you to take full advantage of what M offers.

We’ll start with a brief recap of the main unit where we define variables: the let expression. Then, we’ll talk about how variables (and other things) are identified. Related to identifiers is scope, so we’ll cover that, too. Next time, we’ll expand  our understanding of how variables work by learning about M’s paradigm.
Continue reading

SQL Tip: Double Duty for DECLARE

Just recently, I realized that T-SQL allows variables to be declared and set with a single statement:

DECLARE @UserID int = 1592;

Up until this discovery, I only knew about the more traditional, two-step declaration and assignment syntax:

DECLARE @UserID int;
SET @UserID = 1592;

Continue reading