Your YoY Numbers are Wrong: Here is the Power BI Fix

Опубликовано: 01 Август 2026
на канале: Odet Maimoni
207
5

If today is the 4th of the month, your YoY calculation might be comparing 4 days of data against 30. Here is how I fixed this common DAX bug to get an actual apples-to-apples comparison

In this tutorial, I’ll show you how to create custom functions in Power BI -and fix the SAMEPERIODLASTYEAR bug that happens when selecting the last day of a month.
We’ll build a function that compares the exact same period - not a full previous month - and make sure it also handles leap years correctly for accurate results every time.

0:00 The "Apples-to-Oranges" Problem in YoY reporting
1:15 Why SAMEPERIODLASTYEAR fails with partial months
3:45 The Date Table Bug: How missing future rows trick the engine
6:10 Step 1: Setting up the logic for a reliable period-over-period fix
9:20 Step 2: Writing the Custom Function (UDF) step-by-step
14:30 Comparing the Buggy Result vs. The Custom Fix
18:45 Pro-tip: Why you should use UDFs for all time-intelligence
20:15 Scaling the fix across your entire Power BI model

This is the code for the function:
https://github.com/odetma/Power-BI-Co...