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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
wimsangers
Helper I
Helper I

Measure distinct count

Hi all,

 

I am trying to formulate a measure that counts the id's that are in the status 'build_offer'.

However I only want to count the id's where the status build_offer is not finished yet but the other tasks are.

So in the example below I want to have a count of 2.

Could anyone help me with the formula

 

wimsangers_0-1602685702570.png

 

Thank you in advance.

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @wimsangers ,

You can create this measure:

Count = 
VAR tab =
    ADDCOLUMNS (
        ALL ( 'Table' ),
        "_count",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[process_id] = EARLIER ( 'Table'[process_id] )
                )
            )
    )
RETURN
    COUNTX ( FILTER ( tab, [_count] < 2 ), [_count] )

count.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @wimsangers ,

You can create this measure:

Count = 
VAR tab =
    ADDCOLUMNS (
        ALL ( 'Table' ),
        "_count",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[process_id] = EARLIER ( 'Table'[process_id] )
                )
            )
    )
RETURN
    COUNTX ( FILTER ( tab, [_count] < 2 ), [_count] )

count.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

@v-yingjl  Thank you for your help!

HotChilli
Super User
Super User

Can you explain why the count is 2 please?  I don't see any finished_on values

The count is in this example two because id 4 & 5 have the task 'build_offer' that is not finished yet.

The other tasks have also another task that is not finished yet. That is why I don't want to count these id's.

In this example no tasks are finished, but in my full dataset off course there is.

 

So id's 4 & 5 have the task 'Plan_survey' that is already finished.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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