Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a table with some sample data:
Date | DateIndex | Project | Value | |||
01/01/2020 | 1 | A | 5 | |||
02/01/2020 | 2 | A | 10 | |||
03/01/2020 | 3 | A | 17 | |||
04/01/2020 | 4 | A | 25 | |||
05/01/2020 | 5 | A | 36 | |||
06/01/2020 | 1 | B | 7 | |||
07/01/2020 | 2 | B | 12 | |||
08/01/2020 | 3 | B | 13 | |||
09/01/2020 | 4 | B | 13 | |||
10/01/2020 | 5 | B | 20 | |||
16/02/2020 | 1 | C | 10 | |||
17/02/2020 | 2 | C | 18 | |||
18/02/2020 | 3 | C | 23 |
From this I'm creating a table visual as follows:
Project | Dates | 1 | 2 | 3 | 4 | 5 | |
A | 5 | 10 | 17 | 25 | 36 | |
B | 7 | 12 | 13 | 13 | 20 | |
C | 10 | 18 | 23 |
As you can see, project C will have no value for dates 4 & 5 with it not exisiting in the dataset
What i'm trying to do is create a dax measure that will populate the gaps in the table above with the lastnonblank value for the particular project. So the outcome would be like the below, with the value of 23 being assigned to dates 4 & 5.
Project | Dates | 1 | 2 | 3 | 4 | 5 | |
A | 5 | 10 | 17 | 25 | 36 | |
B | 7 | 12 | 13 | 13 | 20 | |
C | 10 | 18 | 23 | 23 | 23 |
Realistically there would be 10 to 20 projects with various dates, but I would want every projects to go to the max available dateindex, carrying forward any last non blank value
Any ideas?
Solved! Go to Solution.
Hi @RyanBentham
You can try the following steps.
1 Create a Calculated table
New Table = CROSSJOIN(VALUES('Table'[Project]),VALUES('Table'[DateIndex]))
2 Create a Measure
Filled Value =
VAR max_index =
CALCULATE (
MAX ( 'New Table'[DateIndex] ),
ALLEXCEPT ( 'New Table', 'New Table'[Project] ),
NOT ( ISBLANK ( 'New Table'[Value] ) )
)
VAR max_val =
CALCULATE (
MAX ( 'New Table'[Value] ),
FILTER (
ALL ( 'New Table' ),
'New Table'[Project] = SELECTEDVALUE ( 'New Table'[Project] )
&& 'New Table'[DateIndex] = max_index
)
)
VAR res =
IF (
ISBLANK ( SELECTEDVALUE ( 'New Table'[Value] ) ),
max_val,
SELECTEDVALUE ( 'New Table'[Value] )
)
RETURN
IF (
HASONEFILTER ( 'New Table'[Project] ) && HASONEFILTER ( 'New Table'[DateIndex] ),
res,
IF (
HASONEFILTER ( 'New Table'[Project] ),
CALCULATE (
SUM ( 'New Table'[Value] ),
ALLEXCEPT ( 'New Table', 'New Table'[Project] )
),
CALCULATE (
SUM ( 'New Table'[Value] ),
ALLEXCEPT ( 'New Table', 'New Table'[DateIndex] )
)
)
)
The result looks like this:
For more details, you can refer the attached pbix.
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @RyanBentham
You can try the following steps.
1 Create a Calculated table
New Table = CROSSJOIN(VALUES('Table'[Project]),VALUES('Table'[DateIndex]))
2 Create a Measure
Filled Value =
VAR max_index =
CALCULATE (
MAX ( 'New Table'[DateIndex] ),
ALLEXCEPT ( 'New Table', 'New Table'[Project] ),
NOT ( ISBLANK ( 'New Table'[Value] ) )
)
VAR max_val =
CALCULATE (
MAX ( 'New Table'[Value] ),
FILTER (
ALL ( 'New Table' ),
'New Table'[Project] = SELECTEDVALUE ( 'New Table'[Project] )
&& 'New Table'[DateIndex] = max_index
)
)
VAR res =
IF (
ISBLANK ( SELECTEDVALUE ( 'New Table'[Value] ) ),
max_val,
SELECTEDVALUE ( 'New Table'[Value] )
)
RETURN
IF (
HASONEFILTER ( 'New Table'[Project] ) && HASONEFILTER ( 'New Table'[DateIndex] ),
res,
IF (
HASONEFILTER ( 'New Table'[Project] ),
CALCULATE (
SUM ( 'New Table'[Value] ),
ALLEXCEPT ( 'New Table', 'New Table'[Project] )
),
CALCULATE (
SUM ( 'New Table'[Value] ),
ALLEXCEPT ( 'New Table', 'New Table'[DateIndex] )
)
)
)
The result looks like this:
For more details, you can refer the attached pbix.
Best Regards
Caiyun Zheng
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@RyanBentham , Try a new measure like
if(isblank(max(Table[Value])), calculate(lastnonblankvalue(Table[DateIndex], max(Table[Value])), allexcept(Table, Table[project])), max(Table[Value]))
Thanks, although didn't quite work for me 😞
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
65 | |
63 | |
52 | |
37 | |
36 |
User | Count |
---|---|
79 | |
67 | |
60 | |
45 | |
45 |