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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
adii
Helper I
Helper I

How to countrows based on two columns

Hello , I’m wondering how solve technical problem with distinctly values. I would like show and count only distinct rows based on two columns. Problem shows bellow in random table

Date

Country

Port

Name

2023-01-01

USA

Tex

Bat

2023-01-01

USA

Tex

Cat

2023-02-05

Qatar

Al

Al bat

2023-06-07

USA

Tex

Bat

Etc

Etc

Etc

Etc

 

I would receive number of rows like below

Bat 2

Cat 1

Al bat 1

 

Countrows has to be depending on Date and Name columns

 

Thanks all

3 REPLIES 3
Ritaf1983
Super User
Super User

Hi @adii 

For the visual with just name and count, regular count works accurately :

Ritaf1983_0-1697871730763.png

If the desired result is the first table with adding count, than you can create a measure with the formula :

count 2 = CALCULATE([regular countrows],ALLSELECTED('Table'[Port],'Table'[Date]))

Ritaf1983_1-1697871840198.png

Link to the sample file 

 

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hello, thanks you but i wasn't too clear . I have more complicated issue . Below i modified my table

Date ExitPortNameUpdate
2023-01-01TEXCat2023-02-01
2023-01-14TEXBat2023-02-01
2023-01-14AIAI bat2023-02-01
2023-01-01TEXCat2023-02-02
2023-01-14TEXBat2023-02-02
2023-01-14AIAI bat2023-02-02
2023-01-24TEXBat2023-02-03
2023-01-24TEXCat2023-02-03

And Now I would like calculate  distinct row.
I would like recive


Bat 2 (first data exit 2023-01-14 second 2023-01-24)

Cat 2 (first data exit 2023-01-01 second 2023-01-24)

etc

 

In case of bat which exit is first data exit 2023-01-14 we see him in table twice time (two updates date 2023-01-01 and 2023-01-02)

 

I hope im clear now 

 

Ashish_Mathur
Super User
Super User

Hi,

Drag Name to the visual and write this measure

Measure = distinctcount(Data[Date])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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