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.
Dear community,
I’m having trouble aligning the previous data with the current data on a specific date in a matrix table.
I have a matrix table displaying the Total for specific dates each month, and I want to add a second row to show the Total Prior, similar to the example below.
Application Date and Settlement Date are on two different date dimension.
The issue I’m facing is that the Total Prior is appearing on the next day, even though there are no Total sales.
Solved! Go to Solution.
Hi,
Thank you for your message, and I thought only two dim tables were there, and I just add the condition in the measure REMOVEFILTERS()
If there are more dimension tables, I need to specify which dimension tables to apply REMOVEFILTERS() function in the measure.
Please check the below fixed-measure and the attached pbix file whether it suits your requirement.
LastNonBlank amount: =
VAR _t =
ADDCOLUMNS (
CALCULATETABLE (
SUMMARIZE (
Data,
DimApplicationDate[Year-Month],
DimApplicationDate[Year-Month sort],
DimSettlementDate[Date]
),
REMOVEFILTERS (DimApplicationDate), REMOVEFILTERS(DimSettlementDate)
),
"@total", [Total:]
)
VAR _rownumber =
ADDCOLUMNS (
_t,
"@rownumber",
ROWNUMBER (
_t,
ORDERBY (
DimApplicationDate[Year-Month sort], ASC,
DimSettlementDate[Date], ASC
)
)
)
VAR _currentrownumber =
MAXX (
FILTER (
_rownumber,
DimApplicationDate[Year-Month sort]
= MAX ( DimApplicationDate[Year-Month sort] )
&& DimSettlementDate[Date] = MAX ( DimSettlementDate[Date] )
),
[@rownumber]
)
VAR _prevrownumber = _currentrownumber - 1
RETURN
MAXX ( FILTER ( _rownumber, [@rownumber] = _prevrownumber ), [@total] )
Hi,
Please check the below picture and the attached pbix file.
ROWNUMBER function (DAX) - DAX | Microsoft Learn
LastNonBlank amount: =
VAR _t =
ADDCOLUMNS (
CALCULATETABLE (
SUMMARIZE (
Data,
DimApplicationDate[Year-Month],
DimApplicationDate[Year-Month sort],
DimSettlementDate[Date]
),
REMOVEFILTERS ()
),
"@total", [Total:]
)
VAR _rownumber =
ADDCOLUMNS (
_t,
"@rownumber",
ROWNUMBER (
_t,
ORDERBY (
DimApplicationDate[Year-Month sort], ASC,
DimSettlementDate[Date], ASC
)
)
)
VAR _currentrownumber =
MAXX (
FILTER (
_rownumber,
DimApplicationDate[Year-Month sort]
= MAX ( DimApplicationDate[Year-Month sort] )
&& DimSettlementDate[Date] = MAX ( DimSettlementDate[Date] )
),
[@rownumber]
)
VAR _prevrownumber = _currentrownumber - 1
RETURN
MAXX ( FILTER ( _rownumber, [@rownumber] = _prevrownumber ), [@total] )
This is amazing and thank you so much. However, when I add slicers, part of the results appears to change.
This is the pbix file I'm using Tommy_K78_pbix
Hi,
Thank you for your message, and I thought only two dim tables were there, and I just add the condition in the measure REMOVEFILTERS()
If there are more dimension tables, I need to specify which dimension tables to apply REMOVEFILTERS() function in the measure.
Please check the below fixed-measure and the attached pbix file whether it suits your requirement.
LastNonBlank amount: =
VAR _t =
ADDCOLUMNS (
CALCULATETABLE (
SUMMARIZE (
Data,
DimApplicationDate[Year-Month],
DimApplicationDate[Year-Month sort],
DimSettlementDate[Date]
),
REMOVEFILTERS (DimApplicationDate), REMOVEFILTERS(DimSettlementDate)
),
"@total", [Total:]
)
VAR _rownumber =
ADDCOLUMNS (
_t,
"@rownumber",
ROWNUMBER (
_t,
ORDERBY (
DimApplicationDate[Year-Month sort], ASC,
DimSettlementDate[Date], ASC
)
)
)
VAR _currentrownumber =
MAXX (
FILTER (
_rownumber,
DimApplicationDate[Year-Month sort]
= MAX ( DimApplicationDate[Year-Month sort] )
&& DimSettlementDate[Date] = MAX ( DimSettlementDate[Date] )
),
[@rownumber]
)
VAR _prevrownumber = _currentrownumber - 1
RETURN
MAXX ( FILTER ( _rownumber, [@rownumber] = _prevrownumber ), [@total] )
Thanks, this worked like a charm!
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 |