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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
NeroTolentino
Frequent Visitor

Show Value of Previous Non Blank if Filter Selected Has No Value

Hello,

 

Hope you can help me with a solution.  I need to get the Last Non Blank Value. In the images below, I need Image 2 to show 89.00%, since it has the most recent non blank value. Same if I filter to Dec-2022, I'd like the card to show the most recent non blank which is Jun-2022 score. Image 3 shows the model. The closest solution I found is using LastNonBlank Date but the fields came from the same table so I wasn't able to get the desired solution.

 

Here the PBI_File for reference. Thanks in advance!

 

Image 1

Img1.png

 

 

 

 

 

Image 2

Img2.png

 

Image 3

Img3.png

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Thank you for providing the sample data. That helps a lot with proposing a potential solution.

There's a problem with your statement

"There is no data for May-2022"

There is in fact data for May - two rows with an empty string. That's not good.  Can you either not have these rows, or replace the empty strings with null ?

 

Average Score % = 
var m=max(DateTable[Date])
var lm=CALCULATE(LASTNONBLANK(ScoreTable[Date],sum(ScoreTable[Date])),all(ScoreTable),ScoreTable[Date]<=m)
return calculate(AVERAGE(ScoreTable[Score %]),DateTable[Date]=lm)

see attached.

 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Thank you for providing the sample data. That helps a lot with proposing a potential solution.

There's a problem with your statement

"There is no data for May-2022"

There is in fact data for May - two rows with an empty string. That's not good.  Can you either not have these rows, or replace the empty strings with null ?

 

Average Score % = 
var m=max(DateTable[Date])
var lm=CALCULATE(LASTNONBLANK(ScoreTable[Date],sum(ScoreTable[Date])),all(ScoreTable),ScoreTable[Date]<=m)
return calculate(AVERAGE(ScoreTable[Score %]),DateTable[Date]=lm)

see attached.

 

Exactly how I need it. Thank you!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.