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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
SG-01
Helper I
Helper I

Show the last value of each quarter

Hi there,

I have the following data:

QuantityDate
2031-1-2023
1010-2-2023
1020-2-2023
3020-3-2023

I want to show in my visual for Q1 the quantity, but only the latest one, so the quantity of 30 for 20-3-2023. If I now select Q1 in my slicer, it shows the total quantity for Q1. What kind of measure can I make that it will always shows the latest value of each Quarter?

Thanks!

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @SG-01 ,

I created some data:

vyangliumsft_0-1674021675709.png

Here are the steps you can follow:

1. Create measure.

average quantity for each quarter =
var _select=SELECTEDVALUE('Table'[Quarter])
return
AVERAGEX(FILTER(ALL('Table'),'Table'[Quarter]=_select),[Quantity])
last value of each quarter =
var _select=SELECTEDVALUE('Table'[Quarter])
var _maxdate=
MAXX(FILTER(ALL('Table'),'Table'[Quarter]=_select),[Date])
return
SUMX(FILTER(ALL('Table'),'Table'[Date]=_maxdate),[Quantity])

2. Result:

vyangliumsft_1-1674021675712.png

 

Best Regards,

Liu Yang

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

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @SG-01 ,

I created some data:

vyangliumsft_0-1674021675709.png

Here are the steps you can follow:

1. Create measure.

average quantity for each quarter =
var _select=SELECTEDVALUE('Table'[Quarter])
return
AVERAGEX(FILTER(ALL('Table'),'Table'[Quarter]=_select),[Quantity])
last value of each quarter =
var _select=SELECTEDVALUE('Table'[Quarter])
var _maxdate=
MAXX(FILTER(ALL('Table'),'Table'[Quarter]=_select),[Date])
return
SUMX(FILTER(ALL('Table'),'Table'[Date]=_maxdate),[Quantity])

2. Result:

vyangliumsft_1-1674021675712.png

 

Best Regards,

Liu Yang

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

Thanks so much!

And what if my table has an extra column with months where I have another slicer with month numbers. So if you click on more than one month number, it also calculates the average, but if the input is just one month number it shows the value for that month. I need that in the same measure as for the quarters. So based on the input of the slicer the value will be showed.


And how can I change the measure for the average quantity that it will also calculate the average when multiple quarters are selected. That does not seem to work right now.

JonasBI
Helper I
Helper I

Measure = CLOSINGBALANCEQUARTER(SUM(Table[Quantity]), Table[Date]

@JonasBI Does not seem to work, I get no values back.

Maybe better for me that I want the average of each quarter of a measure. So the measure calculates the average quantity for each quarter. How can I generate that measure?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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