DAX UDF Parameter Modes: Stop Using VAL and EXPR Wrong episode artwork

EPISODE · Nov 19, 2025 · 21 MIN

DAX UDF Parameter Modes: Stop Using VAL and EXPR Wrong

from M365.FM - Modern work, security, and productivity with Microsoft 365 · host Mirko Peters - Founder of m365.fm, m365.show and m365con.net

(00:00:00) The DAX UDF Dilemma (00:00:32) The Context Transition Trap (00:00:47) VAL vs XPR: The Core Decision (00:01:39) The Best Customers Example (00:02:52) When to Use VAL and XPR (00:04:54) The Context Transition Problem (00:05:57) Fixing the Context Transition Trap (00:08:59) Materializing with Add Columns (00:13:06) Parameter Types and Casting (00:16:12) Authoring Checklist for UDFs In this episode of M365.fm, Mirko Peters shows why most DAX user‑defined functions fail quietly — not because the math is wrong, but because parameter modes, context transition, and materialization are misunderstood.WHAT YOU WILL LEARNThe real difference between VAL and EXPR: pass‑by‑value vs pass‑by‑expression and why it changes when your logic runsWhy using VAL for context‑sensitive metrics freezes results and produces “comfortably wrong” numbersHow EXPR behaves like a measure, and why you must wrap it with CALCULATE inside iterators to respect the current rowHow to stop recomputing expensive expressions by materializing them once with ADDCOLUMNS and reusing the columnHow data types, coercion, and BLANK handling can quietly change your results in UDFsA practical “Mode → Move → Make” checklist you can apply to every new DAX function you writeTHE CORE INSIGHTDAX UDFs are not magic; they are just DAX with sharper edges. VAL vs EXPR decides whether you pass a frozen scalar or a living expression; context transition decides whether row context becomes filter context; materialization decides whether you pay the same expensive cost hundreds of times or once. If you ignore those three decisions, your UDFs will work in demos and betray you in production.WHO THIS EPISODE IS FORThis episode is ideal for Power BI developers, DAX authors, semantic model owners, and anyone building reusable calculation logic in enterprise models. If you’ve ever had a “correct” UDF that fails on slicers, ignores the current row, or suddenly becomes slow at scale, this conversation gives you the mental model and patterns to fix it.ABOUT THE HOSTMirko Peters is a Microsoft 365 and data platform consultant focused on building trustworthy, reusable semantic models on Power BI and Microsoft Fabric. Through M365.fm, Mirko shares practical DAX patterns, performance lessons, and modeling approaches that help teams move from fragile measures to robust, well‑behaved UDFs that stand up under real workloads.Become a supporter of this podcast: https://www.spreaker.com/podcast/m365-fm-modern-work-security-and-productivity-with-microsoft-365--6704921/support.

(00:00:00) The DAX UDF Dilemma (00:00:32) The Context Transition Trap (00:00:47) VAL vs XPR: The Core Decision (00:01:39) The Best Customers Example (00:02:52) When to Use VAL and XPR (00:04:54) The Context Transition Problem (00:05:57) Fixing the Context Transition Trap (00:08:59) Materializing with Add Columns (00:13:06) Parameter Types and Casting (00:16:12) Authoring Checklist for UDFs In this episode of M365.fm, Mirko Peters shows why most DAX user‑defined functions fail quietly — not because the math is wrong, but because parameter modes, context transition, and materialization are misunderstood.WHAT YOU WILL LEARNThe real difference between VAL and EXPR: pass‑by‑value vs pass‑by‑expression and why it changes when your logic runsWhy using VAL for context‑sensitive metrics freezes results and produces “comfortably wrong” numbersHow EXPR behaves like a measure, and why you must wrap it with CALCULATE inside iterators to respect the current rowHow to stop recomputing expensive expressions by materializing them once with ADDCOLUMNS and reusing the columnHow data types, coercion, and BLANK handling can quietly change your results in UDFsA practical “Mode → Move → Make” checklist you can apply to every new DAX function you writeTHE CORE INSIGHTDAX UDFs are not magic; they are just DAX with sharper edges. VAL vs EXPR decides whether you pass a frozen scalar or a living expression; context transition decides whether row context becomes filter context; materialization decides whether you pay the same expensive cost hundreds of times or once. If you ignore those three decisions, your UDFs will work in demos and betray you in production.WHO THIS EPISODE IS FORThis episode is ideal for Power BI developers, DAX authors, semantic model owners, and anyone building reusable calculation logic in enterprise models. If you’ve ever had a “correct” UDF that fails on slicers, ignores the current row, or suddenly becomes slow at scale, this conversation gives you the mental model and patterns to fix it.ABOUT THE HOSTMirko Peters is a Microsoft 365 and data platform consultant focused on building trustworthy, reusable semantic models on Power BI and Microsoft Fabric. Through M365.fm, Mirko shares practical DAX patterns, performance lessons, and modeling approaches that help teams move from fragile measures to robust, well‑behaved UDFs that stand up under real workloads.Become a supporter of this podcast: <a...

NOW PLAYING

DAX UDF Parameter Modes: Stop Using VAL and EXPR Wrong

0:00 21:24

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

Frequently Asked Questions

How long is this episode of M365.FM - Modern work, security, and productivity with Microsoft 365?

This episode is 21 minutes long.

When was this M365.FM - Modern work, security, and productivity with Microsoft 365 episode published?

This episode was published on November 19, 2025.

What is this episode about?

(00:00:00) The DAX UDF Dilemma (00:00:32) The Context Transition Trap (00:00:47) VAL vs XPR: The Core Decision (00:01:39) The Best Customers Example (00:02:52) When to Use VAL and XPR (00:04:54) The Context Transition Problem (00:05:57) Fixing the...

Is there a transcript available for this episode?

Yes, a full transcript is available for this episode. You can read the complete transcript on the episode page.

Can I download this M365.FM - Modern work, security, and productivity with Microsoft 365 episode?

Yes, you can download this episode by clicking the download button on the episode player, or subscribe to the podcast in your preferred podcast app for automatic downloads.
URL copied to clipboard!