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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Distinct Count rows when there is data

Hi All,

 

I am trying to create a measure that will return the same output as "Period with Rev". It is the distinct count of period when there is data. Does anyone know how I can achieve the same output?

 

beekee_0-1619304816082.png

 

Thanks.

 

Regards,

BK

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

 Hi, @Anonymous 

 

Try to create a measure below:

Period with Rev =
VAR PeriodWithRev =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Period] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Revenue] <> BLANK () )
    )
RETURN
    IF ( ISBLANK ( SELECTEDVALUE ( 'Table'[Revenue] ) ), BLANK (), PeriodWithRev )

Sample:

v-angzheng-msft_0-1619501576069.jpeg

Result:

v-angzheng-msft_1-1619501576072.jpeg

Change the data and test it:

v-angzheng-msft_2-1619501576073.jpeg

v-angzheng-msft_3-1619501576076.jpeg

Please refer to the attachment below for details

 

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

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

View solution in original post

2 REPLIES 2
v-angzheng-msft
Community Support
Community Support

 Hi, @Anonymous 

 

Try to create a measure below:

Period with Rev =
VAR PeriodWithRev =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Period] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Revenue] <> BLANK () )
    )
RETURN
    IF ( ISBLANK ( SELECTEDVALUE ( 'Table'[Revenue] ) ), BLANK (), PeriodWithRev )

Sample:

v-angzheng-msft_0-1619501576069.jpeg

Result:

v-angzheng-msft_1-1619501576072.jpeg

Change the data and test it:

v-angzheng-msft_2-1619501576073.jpeg

v-angzheng-msft_3-1619501576076.jpeg

Please refer to the attachment below for details

 

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

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

Ashish_Mathur
Super User
Super User

Hi,

Assuming the Period column has been dragged from the Calendar Table and revenue is a measure, try this measure

Period with rev = countrows(filter(values(calendar[period]),[revenue]>0))

Hope this helps.


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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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