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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

need to count a colum with names

Help please!!!

 

dataset of 2 years with names like this example:

 

Name                Year

anna                   2022

John                  2022

karen                 2022

John                  2023

 

i want a colum next to it with the answer "Both years"  or "single year"   so john would be "Both years"     and Karen "single year"

 

 

many thanks :):)

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Anonymous 

try like:

Column = 
IF(
   COUNTROWS(
       FILTER(
           TableName, 
        TableName[Name]=EARLIER(TableName[Name])
       )
    )=2,
   "Both years",
    "Single years"
)

 

worked like:

FreemanZ_0-1678193966791.png

 

View solution in original post

4 REPLIES 4
FreemanZ
Super User
Super User

hi @Anonymous 

try like:

Column = 
IF(
   COUNTROWS(
       FILTER(
           TableName, 
        TableName[Name]=EARLIER(TableName[Name])
       )
    )=2,
   "Both years",
    "Single years"
)

 

worked like:

FreemanZ_0-1678193966791.png

 

FreemanZ
Super User
Super User

hi @Anonymous 

try like:

Column =
IF(
   COUNTROWS(
       TableName, 
       TableName[Name]=EARLIER(TableName[Name])
    )=2,
   "Both years",
    "Single years"
)
Anonymous
Not applicable

this doesnt work i get a error in =Earlier rule 

there are something missing, see the latest reply. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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