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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
o59393
Post Prodigy
Post Prodigy

Return latest value regardless of date slicer

Hi all

 

I need to have a measure that returns the latest % value. For example if one value is for March 2019 and the other one for november 2019, the measure should return me the value of november 2019.

 

Regardless of which date you have on the date slicer the condition above should be kept.

 

I created the following dax:

 

 

Most Recent Score = 
CALCULATE(
AVERAGE(NEXT[NEXT]), 
LASTNONBLANK('date'[Start of Month],
AVERAGE(NEXT[NEXT])), 
ALL('date'[Start of Month])
)

 

 

However on my kpi card, is returning me a blanK(), but the value of the example should be 88.43% (value of november in the table):

 

DDSFSDSFS.JPG

 

 

How can I get it right?

 

pbix https://1drv.ms/u/s!ApgeWwGTKtFdhmc6hMVmmqyeKKwZ?e=Lh6sK2

 

Thanks.

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi @o59393 ,

 

Please try the following measure.

 

New Measure = 
var max_date = CALCULATE(MAX(NEXT[Date]),ALLSELECTED())
var lastest_ = CALCULATE(AVERAGE(NEXT[NEXT]),FILTER(ALL('date'),'date'[Start of Month]=max_date),ALLSELECTED(facilities))
return
lastest_

 

The result like this,

 

Return 1.jpg

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

11 REPLIES 11
v-zhenbw-msft
Community Support
Community Support

Hi @o59393 ,

 

Sorry for the late reply.

We think the facility_id 6408 doesn’t have the data in 2020. So the card shows the blank.

We notice your model has some custom interactions, please make sure all slicers are working for the two visuals.

 

Return 1.jpg

 

Return 2.jpg

 

If you have any question, please kindly ask here and we will try to resolve it.

 

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

Hi @v-zhenbw-msft 

 

That is correct 2020 is empty for that facility. However, is there any possibility it can still return the latest value when the slicer date of month is november 2019 and above for that particular facility id (and any other too depending on their latest NEXT[Date]) ?

 

I chose december 2019 and got a blank, but it should return the latest value, in this case november based on the NEXT[Date] for the id 6408:

 

slkdlsklksldksalkdlsaklklsk.JPG

 

My final dashboard I have a table like this:

jskdjskjd.JPG

 

The other metrics you see on the table are 12 rolling months and they do show with no problem, however NEXT is a particular one that should be only the latest value as we go through the year..

 
Hope this is possible.
 
Thanks a lot !

 

 

 

negi007
Community Champion
Community Champion

@o59393 You will need to block interactions between your filter and the latest value you are showing. This way your filter will not impact the latest value. Go to format and select edit interactions. Here, select the none (round circle) to block interactions between filters and the latest value.




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Hi @negi007 

 

The thing is that I can't block the interactions since I have a table (seen in my previous comment) that contains other KPI's.

 

Blocking the interactions wouldn't allow the other ones to work. 

 

Regards!

 

 

 

Hi @o59393 ,

 

Please try the following measure.

 

New Measure = 
var max_date = CALCULATE(MAX(NEXT[Date]),ALLSELECTED())
var lastest_ = CALCULATE(AVERAGE(NEXT[NEXT]),FILTER(ALL('date'),'date'[Start of Month]=max_date),ALLSELECTED(facilities))
return
lastest_

 

The result like this,

 

Return 1.jpg

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

I can't access the pbix solution.  Looking for something similiar.  Can you please repost?

Hi @v-zhenbw-msft 

 

So it finally worked 🙂

 

I did a small arrangement to your last DAX in order to get the latest result by selecting a year and month:

 

New Measure = 
var max_date = CALCULATE(MAX(NEXT[Date]),ALL('date'[Start of Month]),ALL('date'[Year]))
var lastest_ = CALCULATE(AVERAGE(NEXT[NEXT]),FILTER(ALL('date'),'date'[Start of Month]=max_date),ALLSELECTED(facilities))
return
lastest_

 

ksaldksaldksadlalkasd.JPG

 

Thanks for your help and patience in this problem I had.

 

Regards !

Hi @v-zhenbw-msft 

 

Thanks for the help!

 

I checked the measure and I see it works only when you select year and start of month to all.

 

I would like to get the result (latest value) when you select the year, start of month and the facility id (this one already works).

 

I know we can get that with blocking the interactions, however i don't want that to be activated since it would affect me other metrics in a table.

 

So my experect result would be something like (could only do it visually):

 

kjskjsdk.JPGjksakjdasdfdf.JPG

 

So as you see my expected result would be to get the latest value when you select year, month and facility without havind to block the interactions.

 

Thanks a million for the help!

v-zhenbw-msft
Community Support
Community Support

Hi @o59393 ,

 

We can create a new measure to meet your requirement.

 

New Measure = 
var selected_ = MIN(facilities[facility_id])
var max_date = CALCULATE(MAX(NEXT[Date]),FILTER(facilities,facilities[facility_id]=selected_))
return
CALCULATE(AVERAGE(NEXT[NEXT]),FILTER('date','date'[Start of Month]=max_date))

 

Put it in the card and the result like this,

 

Return 1.jpg

 

Return 2.jpg

 

If you have any question, please kindly ask here and we will try to resolve it.

BTW, pbix as attached.       

 

Best regards,

 

Community Support Team _ zhenbw

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

Hi @v-zhenbw-msft 

 

Really appreciate your help!

 

I noticed that if you selec the year in the pbix the measure wont work.

 

I added to the metric the following criteria but it didnt work:

 

New Measure = 
var selected_ = MIN(facilities[facility_id])
var selected_2 = MIN(facilities[bottler])
var selected_3 = MIN(facilities[region])
var max_date = CALCULATE(MAX(NEXT[Date]),FILTER(facilities,facilities[facility_id]=selected_),facilities[bottler]=selected_2,facilities[region]=selected_3)
return
CALCULATE(AVERAGE(NEXT[NEXT]),FILTER('date','date'[Start of Month]=max_date),'date'[Year]=max_date)

 

Basically I added the bottler and region variables.

 

Within the first calculate I added the selected2 and selected 3.

 

And in the last calculate I added the year.

 

Can you please help how to get it right?

 

I attach pbix 

 

https://1drv.ms/u/s!ApgeWwGTKtFdhm67GNHb8nJIwiDt?e=Di98Do

 

Thanks a million!

Hi @v-zhenbw-msft 

 

Hope you're doing well. Any advise on how to be include the year too on the dax measure like mentioned above?

 

Thanks!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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