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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply

How to count the most recent value in a column when that value is 0

Hello,

I have spent days on this and cannot figure it out. I hope someone can help, please

I'm tracking skills so my model has skillnames, achieved levels, dates and persons name. (This is just a test - my actual table have millions of records but behaves the same)

justlearning50_0-1705506246504.png

 

Im using this measure to get the latest value of each skill for each person:  

Latest result = var _maxDate = MAXX
(
    FILTER
    (
        ALLSELECTED(Sheet1),
    Sheet1[Skill name]= MAX(Sheet1[Skill name])
    ),
    Sheet1[date])
   
    return
CALCULATE
(
     MAX(Sheet1[achieved level]),
    FILTER
    (
        Sheet1,
         Sheet1[Skill name]= MAX(Sheet1[Skill name]) && Sheet1[date] = _maxDate
    )
)
It works and I can create this table 
justlearning50_1-1705506336777.png

I am then using this measure to count up the number of each skill level: 

 

num Level 4 = CALCULATE(
    COUNTROWS(Sheet1),
    FILTER(Sheet1,
    Sheet1[Latest result] = 4
    ))
which gives the answer as 5 which is correct. This works for all the numbers except 0. the measure for 0 is the exact same:
num not started = CALCULATE(
    COUNTROWS(Sheet1),
    FILTER(Sheet1,
    Sheet1[Latest result] = 0
    ))
 
but this gives me 13 which is the total number of 0's in the table not just those which are the latest value. Does anyone know why this is? If I change all my 0's to 10 for instance it works fine. So it is something related to the fact that I'm asking it to count the latest 0 values. 
I hope my issue is clear, but please ask if not.
Any insight or help is most welcome.
Thank you.
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@justlearning50 , try like

 

Countrows(filter(Sheet1, not(isblank([Latest result])) && [Latest result] =0))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@justlearning50 , try like

 

Countrows(filter(Sheet1, not(isblank([Latest result])) && [Latest result] =0))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak . That worked.

Why is this need for 0 only? is it a case that there is a default blank for the rows that are not the latest score, and the measure was reading these as 0? If I create a table with the achieved score and the latest score, I only see the rows with the latest score not all the rows with a blank.

Thank you again.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.