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.
Hola, community.
I have a fact table which brings values per category and inconsistently. Meaning some days are missing and those missing days differ per category. I want to fill those gaps with the dates for each category and give them last no blank value (corresponding to the category). I would prefer this doing in PQ. but DAX is also appreciated ( calculated column).
I checked a nioce solution here but it does not seem to mind the category so was struggling to apply that.
The current situation:
Desired solution:
Solved! Go to Solution.
@Aleksandra_MLT
Please refer to updated sample file with the calculated table proposed solution
Table 2 =
ADDCOLUMNS (
CROSSJOIN (
CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
ALLNOBLANKROW ( 'Table'[Category] )
),
"Value",
MAXX (
TOPN (
1,
FILTER (
'Table',
'Table'[Category] = EARLIER ( 'Table'[Category] )
&& 'Table'[Date] <= EARLIER ( [Date] )
),
'Table'[Date]
),
'Table'[Value]
)
)
Hi @Aleksandra_MLT
Please refer to attached sample file with the proposed solution
Value Measure =
VAR CurrentDate = MAX ( 'Date'[Date] )
VAR CurrentCategoryTable = CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Category] ) )
VAR TableBefore = FILTER ( CurrentCategoryTable, 'Table'[Date] < CurrentDate )
VAR PreviousRecord = TOPN ( 1, TableBefore, 'Table'[Date] )
VAR Result = SUMX ( PreviousRecord, 'Table'[Value] )
RETURN
IF (
ISINSCOPE ( 'Table'[Category] ),
COALESCE ( SUM ( 'Table'[Value] ), Result )
)
Thank you for quick reply, @tamerj1 !
But I would prefer a calculated column cause I need a row context. I mentioned it as well 🙂
A calculated column cannot add new rows. Perhaps you mean a new calculated table?
@tamerj1 , indeed, CC will not expand table, apologies for confusion. So yes, either calculated table either power query.
@Aleksandra_MLT
Please refer to updated sample file with the calculated table proposed solution
Table 2 =
ADDCOLUMNS (
CROSSJOIN (
CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
ALLNOBLANKROW ( 'Table'[Category] )
),
"Value",
MAXX (
TOPN (
1,
FILTER (
'Table',
'Table'[Category] = EARLIER ( 'Table'[Category] )
&& 'Table'[Date] <= EARLIER ( [Date] )
),
'Table'[Date]
),
'Table'[Value]
)
)
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 |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
11 |