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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
JasonBurdetts
Frequent Visitor

Generating Missing Data

I am attempt to solve an issue where I believe I am starting with some misconceptions, so I would like to explain a very simple scenario, the solution and why the solution works.

Image a Dimension table having Hours 1 to 12 (in practice, a Date table, but I am using hours here to demonstrate).

Hour
1
...
12


Imagine a Fact table having series data Each Value entry is either true, false, or we don't have a data point for the specific hour as in the below table.

HourValue
2True
3True
4False
6True
7True
8False
11True

 

How do I use DAX (or Power Query if more appropriate) to essentially create a SQL left join so that every Hour is represented in the second table, and that blank Values are filled with the value that is the first previous (in hour order) non empty value? In the below table, new values represented in italics.

 

HourValue
1False
2True
3True
4False
5False
6True
7True
8False
9False
10False
11True
12True


This a very simple representation of what I am trying to understand after struggling with LASTNONBLANK and similar functions. The actual Value column is an aggregate of integer entries that that occur in that hour, in which I'd like to use the first previous aggregated value.

 

Jason

1 ACCEPTED SOLUTION
Rupa01
Resolver II
Resolver II

Hi @JasonBurdetts,

Yes, this can be achieved either with DAX or Power Query, but based on your explanation, Power Query may be the simpler option. Since your actual Value column is an aggregate of integer entries that occur within each hour, the key is to aggregate first, then fill down.

The correct order would be:

  1. Aggregate the fact table by Hour
  2. Left join/merge it with the full Hour/Date dimension table
  3. Sort by Hour ascending
  4. Expand to get Value Column
  5. Fill down the aggregated value column. Note: First row would be null after applying Fill down, replace null with 'FALSE'.
Rupa01_0-1782447304399.png
Rupa01_0-1782448090137.png

 

💡 Helpful? Give a Kudos 👍 — keep the community growing
 Solved your issue? Mark as Solution ✔️ — help others find it faster

Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer

View solution in original post

3 REPLIES 3
Kedar_Pande
Super User
Super User

@JasonBurdetts 

Do this in Power Query, much cleaner than DAX here.

 

Start from your Hour list (1-12) and left join the Fact table on Hour. Missing hours show null.
Sort by Hour ascending.
Right-click the Value column, Fill > Down. That carries the last value forward into the blanks.
Replace any leftover null at Hour 1 with False.

 

If this answer helped, please click 👍 or Accept as Solution.
-Kedar
LinkedIn: https://www.linkedin.com/in/kedar-pande

Rupa01
Resolver II
Resolver II

Hi @JasonBurdetts,

Yes, this can be achieved either with DAX or Power Query, but based on your explanation, Power Query may be the simpler option. Since your actual Value column is an aggregate of integer entries that occur within each hour, the key is to aggregate first, then fill down.

The correct order would be:

  1. Aggregate the fact table by Hour
  2. Left join/merge it with the full Hour/Date dimension table
  3. Sort by Hour ascending
  4. Expand to get Value Column
  5. Fill down the aggregated value column. Note: First row would be null after applying Fill down, replace null with 'FALSE'.
Rupa01_0-1782447304399.png
Rupa01_0-1782448090137.png

 

💡 Helpful? Give a Kudos 👍 — keep the community growing
 Solved your issue? Mark as Solution ✔️ — help others find it faster

Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer

@JasonBurdetts If your require to use DAX then pull the hour from the Dim table to the visual and add below DAX Measure to it to get the desired result.

Filled Value = 
VAR CurrentHour =
    MAX ( DimHour[Hour] )
VAR PreviousFactHour =
    CALCULATE (
        MAX ( Fact[Hour] ),
        FILTER (
            ALL ( 'Fact' ),
            'Fact'[Hour] <= CurrentHour
                && NOT ISBLANK ( Fact[Value] )
        )
    )
RETURN
    IF (
        ISBLANK ( PreviousFactHour ),
        BLANK (),
        CALCULATE (
            SELECTEDVALUE ( 'Fact'[Value] ),
            FILTER (
                ALL ( 'Fact' ),
                'Fact'[Hour] = PreviousFactHour
            )
        )
    )

🎯Result -

Rupa01_0-1782448504498.png

 

💡 Helpful? Give a Kudos 👍 — keep the community growing
 Solved your issue? Mark as Solution ✔️ — help others find it faster

Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.