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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
VictorV
Helper I
Helper I

Show last value of column

Hi everyone,

I have table below, and the month filter based on it. I want create a card visual, that it will appear the last Balance whenever I select a month.

For example: If I choose Month "1" in slicer, the card visual should show 3000, and if I select Month "2" it will show 5000, etc.

And if it not select any month, it will show the last value, in this case is 6000.

 

And also, another card visual, that will show the last month balance

For example: If I select month "2", it will show month 1 last balance, in this case is "3000".

 

VictorV_0-1712827314743.png

Please help me, thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @VictorV ,

 

Please try the modified measures:

 

Last Balance = 
var _a = LASTNONBLANK('Table'[Index], 0)
RETURN
CALCULATE(MAX('Table'[Balance]),'Table'[Index]=_a)

Previous Month Last Balance = 
VAR __max_month = MAX('Table'[Month])
VAR __max_date_prev = CALCULATE(MAX('Table'[Date]),'Table'[Month]<__max_month)
var tmp = FILTER(ALL('Table'),[Date]=__max_date_prev)
var max_index = MAXX(tmp,[Index])
RETURN
CALCULATE(MAX('Table'[Balance]),FILTER(ALL('Table'),[Index]=max_index))

 

 

The visual effect of the page is as shown below:

vhuijieymsft_0-1713155071631.png

vhuijieymsft_1-1713155071634.png

vhuijieymsft_0-1713155122860.png

vhuijieymsft_1-1713155122862.png

 

The pbix file has been attached.

 

If you have other questions, please contact me at any time.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @VictorV ,

 

Thanks for the reply from @MattAllington , please allow me to provide another insight:

 

First, create a calculated column to extract the month of the Date column and put it in the Slicer.

Month = 'Table'[Date].[MonthNo]

 

Secondly, create two measures to achieve your needs:

Last Balance =
VAR SelectedMonth = MAX('Table'[Month])
RETURN
CALCULATE(LASTNONBLANK('Table'[Balance], 0), 'Table'[Month] = SelectedMonth)

Previous Month Last Balance =
VAR SelectedMonth = MAX('Table'[Month]) - 1
RETURN
CALCULATE(LASTNONBLANK('Table'[Balance], 0), 'Table'[Month] = SelectedMonth)

 

Place the two measures into the card visual object respectively, and the final page effect is as follows:

vhuijieymsft_0-1712900952304.png
vhuijieymsft_1-1712900952306.png

vhuijieymsft_2-1712900975726.png

vhuijieymsft_3-1712900975728.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

 

Thanks for your replied, It work for "Last Balance". But for the "Previous Month Last Balance" It not getting the last value of last month, it get max value instead. And sometimes the last value in "balance" is not the highest value.

 

However for "Last balance", I use this code instead, I don't know if it would work for "Previous Month Last Blance" or not 

Last Value = CALCULATE(MAX('Table'[Balance]), FILTER('Table','Table'[Index] = MAX('Table'[Index])))
Anonymous
Not applicable

Hi @VictorV ,

 

Please try the modified measures:

 

Last Balance = 
var _a = LASTNONBLANK('Table'[Index], 0)
RETURN
CALCULATE(MAX('Table'[Balance]),'Table'[Index]=_a)

Previous Month Last Balance = 
VAR __max_month = MAX('Table'[Month])
VAR __max_date_prev = CALCULATE(MAX('Table'[Date]),'Table'[Month]<__max_month)
var tmp = FILTER(ALL('Table'),[Date]=__max_date_prev)
var max_index = MAXX(tmp,[Index])
RETURN
CALCULATE(MAX('Table'[Balance]),FILTER(ALL('Table'),[Index]=max_index))

 

 

The visual effect of the page is as shown below:

vhuijieymsft_0-1713155071631.png

vhuijieymsft_1-1713155071634.png

vhuijieymsft_0-1713155122860.png

vhuijieymsft_1-1713155122862.png

 

The pbix file has been attached.

 

If you have other questions, please contact me at any time.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Thanks a lot! it's work perfect for me.

VictorV
Helper I
Helper I

Is there a way to do this without create calendar table?

Not without nasty DAX in calculated columns and measures. Even then, I couldn't guarantee it would always return the correct answer. 

I have a friend that used to write all his letters using Excel. He never leant to use Word, even though that was the right way to do it. In the same way, I guess you could solve the problem using the wrong approach, and rankly there's probably someone on this forum that will show you how to do it the wrong way, but I wouldn't recommend it. 🤷‍♂️

 

If you want an easy calendar table, you can copy the one I created here https://exceleratorbi.com.au/build-reusable-calendar-table-power-query/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
MattAllington
Community Champion
Community Champion

You need a calendar table and some DAX. The DAX logic is covered in this article

https://www.daxpatterns.com/semi-additive-calculations/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors