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
sivarajan21
Post Prodigy
Post Prodigy

The count of existing days is not shown at an aggregated level

Hi,

 

Good Day everyone!

I have below this below sample dataset

Data table

DatePointsSource
12/05/2022 00:00PowysCC-1986Invoice
11/05/2022 00:00PowysCC-1986Invoice
10/05/2022 00:00PowysCC-1986Invoice
12/05/2022 00:00PowysCC-1986Profile
11/05/2022 00:00PowysCC-1986Profile
10/05/2022 00:00PowysCC-1986Profile
30/04/2022 00:00PowysCC-1988Invoice
29/04/2022 00:00PowysCC-1988Invoice
28/04/2022 00:00PowysCC-1988Invoice
30/04/2022 00:00PowysCC-1988Profile
29/04/2022 00:00PowysCC-1988Profile
28/04/2022 00:00PowysCC-1988Profile

 

I want  a dax to count the Date column with respect to their points(aggregating to this level) and don't want source column to affect my count. so literally aggregating date count to points level. I need this dax to show full count of dates for their respective points. 

I created this below measure to solve this but I am getting below problem:

Count of Exisitng Days =
DISTINCTCOUNT ( data[Date] )

The problem i have now is shown in screenshot below:

sivarajan21_0-1682668165118.png

When I don't filter by points it shows only 23 dates which is not correct. There are 46 rows in this data table.  When I filter by PowysCC-1986 it shows 12 days which is correct.

 

Please find the sample file attached here.

 

Can you please me with this?

Thanks in advance.

 

@Ahmedx @grantsamborn 

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

Count of Exisitng Days = 
    if ( 
        ISFILTERED('points'[Points]),
            DISTINCTCOUNT ( data[Date] ),COUNTROWS('data'))

View solution in original post

4 REPLIES 4
sivarajan21
Post Prodigy
Post Prodigy

Hi @Ahmedx ,

 

Thanks for your quick response!

Kudos to you for this solution and it works brilliantly. This measure returns all rows and thanks for this.

However, In my below sample dataset

DatePointsSource
12/05/2022 00:00PowysCC-1986Invoice
11/05/2022 00:00PowysCC-1986Invoice
10/05/2022 00:00PowysCC-1986Invoice
12/05/2022 00:00PowysCC-1986Profile
11/05/2022 00:00PowysCC-1986Profile
10/05/2022 00:00PowysCC-1986Profile
30/04/2022 00:00PowysCC-1988Invoice
29/04/2022 00:00PowysCC-1988Invoice
28/04/2022 00:00PowysCC-1988Invoice
30/04/2022 00:00PowysCC-1988Profile
29/04/2022 00:00PowysCC-1988Profile
28/04/2022 00:00PowysCC-1988Profile

 

for point PowysCC-1986, total date count is 6, out of which only 3 is unique. Because the point id only one but dates are duplicate. so 3 is the distinct one. Although this measure (Count of Exisitng Days =
DISTINCTCOUNT ( data[Date] )) works, correctly at low level(sample data) but when I apply this to my large dataset which contains almost 1 million records, it doesn't work correctly, but where as, this measure works,

Count of Exisitng Days tan =
VAR dates =
SUMMARIZE ( data1, data1[Points], data1[Date].[Date] )
VAR Ext_dates =
COUNTROWS ( dates )
RETURN
Ext_dates

 

The result comparison of both measures are as shown in below screenshot:

sivarajan21_1-1682677646609.png

So now my question would be, is there any alternative measure that can replace measure

'Count of Exisitng Days tan' in terms of efficiency?

 

It would be much appreciated if you can help me on out on this.

Once this is done, I can close this query.

 

Thanks in advance.

I'm not sure if understood you, but the following measure works faster

 

Count of Exisitng Days tan = 
SUMX(DISTINCT('data'[Date]),1)

 

Hi @Ahmedx ,

 

Thanks for your quick response!

I tried this solution and we are pretty closer, and this works faster.

Solution varies slightly as shown below:

sivarajan21_0-1682679981523.png

 

I am sorry i was not able to give a clear picture. Anyway i will accept your previous solution and close this query.

Thanks a lot sir

Ahmedx
Super User
Super User

pls try this

Count of Exisitng Days = 
    if ( 
        ISFILTERED('points'[Points]),
            DISTINCTCOUNT ( data[Date] ),COUNTROWS('data'))

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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