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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Fill in previous values

I need to fill in values for each week based on previous values. Nothing I've tried is working. I have to use DAX, no Power Query.

I have fields for Entity, WeekEnd Date, and Status.

The matrix looks like:

 

WeekEndEntityAEntityBEntityC
June 5Pending Approval  
May 29 In Progress 
May 22 Pending Approval 
May 15In ProgressReady 
May 8Pending Approval Needs Assignment
May 1Ready  
Apr 24Needs Assignment  

 

What I need is to fill in those blanks:

 

WeekEndEntityAEntityBEntityC
June 5Pending ApprovalIn ProgressNeeds Assignment
May 29In ProgressIn ProgressNeeds Assignment
May 22In ProgressPending ApprovalNeeds Assignment
May 15In ProgressReadyNeeds Assignment
May 8Pending Approval Needs Assignment
May 1Ready  
Apr 24Needs Assignment  

 

My PBIX file is linked and has more specific info.

 

I have tried the following and none of these work:

https://community.powerbi.com/t5/Desktop/Fill-blanks-with-previous-value/m-p/492501#M229520

https://community.powerbi.com/t5/Desktop/Fill-blank-values-with-previous-value/m-p/1210628#M539887

 

PLEASE refer to my PBIX file - everything I've tried gives circular dependencies or other problems so there's something about how my data is set up. Thanks for your help!

9 REPLIES 9
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to solve this.  Please do these steps:

 

1.  Make a Date table - you need one if you want to see status now for weeks that don't exist in your data for those entities.  I made this simple one, but much more is possible.  Also, you should turn off Auto Date/Time in this file (and all future files IMO).

Date = ADDCOLUMNS(CALENDAR(MIN(Events[Occurred]), TODAY()),
"WeekStart", [Date] - WEEKDAY([Date]))
 
2.  Add a Date table column to your Events table to make a column that you can relate to the new Date table.
Date = DATE(YEAR(Events[Occurred]), MONTH(Events[Occurred]), DAY(Events[Occurred]))
 
3.  Make a relationship between the Date[Date] and Events[Date] columns.
 
4.  Make this measure 
Most Recent Status = var thisweekmax = MAX('Date'[Date])
return CALCULATE(MIN(Events[Status of Event]), ALL('Date'), 'Date'[Date]<=thisweekmax)
 
5.  Use that matrix in your matrix.  And use the WeekStart column from your Date table for the columns (and keep Entity in the rows).
 
You will get this result
matrix.png
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Unfortunately this didn't work. I'm still trying to find a solution.

FrankAT
Community Champion
Community Champion

Hi @Anonymous,

I agree with @jeroenterheerdt. Power Query is the right place to do this job. EntityA - EntityC must be unpivoted and filled with the missing values.

 

Regards FrankAT

jeroenterheerdt
Microsoft Employee
Microsoft Employee

Why do you have to use DAX? PowerQuery is the place to fix this is, it would be hard to do in DAX.

Anonymous
Not applicable

I'm on a direct query to the server, I can't do any transforms in Power Query.

Hmm, then I am sorry but cannot be of much help. The good news is that that behavior might change soon depending on which source you are using of course.

Anonymous
Not applicable

Unpivoted would look like this:

EntityWeekEndStatus
EntityAJun 5Pending Approval
EntityAMay 29 
EntityAMay 22 
EntityAMay 15In Progress
EntityAMay 8Pending Approval
EntityAMay 1Ready
EntityAApr 24Needs Assignment

 

Does that help with figuring out the DAX?

Hi @Anonymous,

the unpivoted sample data looks like that:

 

21-07-_2020_23-53-53.png

 

But it's not clear what's the rule to fill in the missing values?

Regards FrankAT

Anonymous
Not applicable

@FrankAT  It's probably easier to see what I want in the linked PBIX.

 

Switch your sort on the unpivoted data like I did, sorting on Entity instead of date.

 

What I want is: for each date, if an entity has a status, use that status. If it doesn't have a status, look back to the last non blank status (or date?) and use that.

 

So for Entity A, on May 22 there is no status so it needs to look back to May 15 to find the status to use.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors