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

Join 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.

Reply
Anonymous
Not applicable

How to repeat last values of a column till the end of the matrix?

Hi All,

 

I have a matrix where I need to repeat the last values of the column till the end of the matrix.

 

For example:

 

I have a visual table like the below matrix in my power bi 

 

Report DateJun-21Jul-21Aug-21Sep-21Oct-21Nov-21Dec-21
Jun-2110020010040070010001300
Jul-2150450200100100100100
Aug-21 100350200200200200
Sep-21  100200200200200
Oct-21   500100100100
Nov-21    200300400
Dec-21     100450

 

I want my visual to look like the below table (i.e; the bold values should repeat till Dec-21)

 

Report DateJun-21Jul-21Aug-21Sep-21Oct-21Nov-21Dec-21
Jun-2110020010040070010001300
Jul-2150450200100100100100
Aug-2150100350200200200200
Sep-2150100100200200200200
Oct-2150100100500100100100
Nov-2150100100500200300400
Dec-2150100100500200100450

 


It will be a great help if someone could advise how to write a dax?

Thanks in advance



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

From your screenshot I know that there are two date columns in matrix row and column.

I suggest you to create two unrelated date table based on two date columns in your data table.

Then try this code. Report Date and Date2 table are dax table based on date columns in my data table.

Fill Last Value in Matrix = 
VAR _T1 = GENERATE(VALUES('Table'[Report Date]),VALUES('Table'[Date2]))
VAR _T2 = ADDCOLUMNS(_T1,"Value",CALCULATE(SUM('Table'[Value]),FILTER('Table',AND('Table'[Report Date] = EARLIER([Report Date]),'Table'[Date2]=EARLIER([Date2])))))
VAR _T3 = ADDCOLUMNS(_T2,"MaxDate",MAXX(FILTER(_T2,AND([Date2]=EARLIER([Date2]),[Value]<>BLANK())),[Report Date]))
VAR _T4 = ADDCOLUMNS(_T3,"NewValue",IF([Value] <>BLANK(),[Value],SUMX(FILTER(_T3,AND([Date2]=EARLIER([Date2]),[Report Date]=[MaxDate])),[Value])))
RETURN
SUMX(FILTER(_T4,AND([Report Date] = MAX('Report Date'[Report Date]),[Date2]=MAX(Date2[Date2]))),[NewValue])

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous 

From your screenshot I know that there are two date columns in matrix row and column.

I suggest you to create two unrelated date table based on two date columns in your data table.

Then try this code. Report Date and Date2 table are dax table based on date columns in my data table.

Fill Last Value in Matrix = 
VAR _T1 = GENERATE(VALUES('Table'[Report Date]),VALUES('Table'[Date2]))
VAR _T2 = ADDCOLUMNS(_T1,"Value",CALCULATE(SUM('Table'[Value]),FILTER('Table',AND('Table'[Report Date] = EARLIER([Report Date]),'Table'[Date2]=EARLIER([Date2])))))
VAR _T3 = ADDCOLUMNS(_T2,"MaxDate",MAXX(FILTER(_T2,AND([Date2]=EARLIER([Date2]),[Value]<>BLANK())),[Report Date]))
VAR _T4 = ADDCOLUMNS(_T3,"NewValue",IF([Value] <>BLANK(),[Value],SUMX(FILTER(_T3,AND([Date2]=EARLIER([Date2]),[Report Date]=[MaxDate])),[Value])))
RETURN
SUMX(FILTER(_T4,AND([Report Date] = MAX('Report Date'[Report Date]),[Date2]=MAX(Date2[Date2]))),[NewValue])

Result is as below.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi Rico,

 

Sorry for the late reply

And Thank you so much.
It helped me to create the table how I wanted.

Thanks

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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