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
ybatistamayo
Helper III
Helper III

Count based on a condition by two Column

 

I want to count "Sales Key" only once when "DateKey" and "StoreKey" are equal. The count in this example should give 16

Sin título.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@ybatistamayo 

There is only just another category of blank, can't you just +1?

 

Salidas =
IF(HASONEFILTER(DatosDiariosBasureros[IdVehículo]),DISTINCTCOUNTNOBLANK(DatosDiariosBasureros[SalidaBase]),DISTINCTCOUNTNOBLANK(DatosDiariosBasureros[SalidaBase])+1)
V-pazhen-msft_0-1616485154327.png

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

@ybatistamayo 

There is only just another category of blank, can't you just +1?

 

Salidas =
IF(HASONEFILTER(DatosDiariosBasureros[IdVehículo]),DISTINCTCOUNTNOBLANK(DatosDiariosBasureros[SalidaBase]),DISTINCTCOUNTNOBLANK(DatosDiariosBasureros[SalidaBase])+1)
V-pazhen-msft_0-1616485154327.png

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

=COUNTROWS(SUMMARIZE(GENERATE(VALUES(Data[DateKey]),VALUES(Data[StoreKey])),Data[DateKey],Data[StoreKey]))

Hope this helps.


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

Sorry, it doesn't Work

Hi,

Shae the link from where i can download your PBI file.


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

https://1drv.ms/u/s!AoIRa67hIHkpgRI3N_1eDh7dBQlD?e=ta1NTd 

 

SalesKey = IdDatosDiarioBasurero

DateKey= SalidaBase
StoreKey = TurnoId

 

in this case the total count should give 17.
note there are blank values

 

Hi,

How did you arrive at 17 as the answer?  If you remove duplicates from the SalidaBase and TurnoId columns and filter out the blanks from the TurnoId column, you will be left with 931 unique row combinations.  Please explain clearly.  Alternatively post a simple example and show the expected result on that sample.


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

Hi,

Does the timestamp from the Salidabase column need to be considered or ignored?


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

Hi, the timestamp  is required

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors