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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
justlearning50
Frequent Visitor

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))

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))

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
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.

Top Solution Authors
Top Kudoed Authors