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
luisccmm
Helper II
Helper II

Count Measure Values Ocurrences

Hi,

 

I have a very simple table with around 90thousand rows with 2 Columns, this is a sample that looks like.

 

There around 4 possible Status for each ID (Around 30thousand ID) whereas there around 90thousand rows in the table.

 

 

 

ID              Status

0001          STARTED

0001          ON GOING 

0001          FINISH

0002          STARTED

......

 

 

 

I need to COUNT how many ID have Just 1 Status, 2 Status.... and so on.

 

OUTPUT shoudl look like the following.

 

Count_status_ocurrences        Count IDS              ¿Meaning?

1                                              4.000                      There are 4K Ids that only have 1 Status (any  of STARTED, ON GOING...)

2                                              8.000                      There are 8K ids that have 2 status  (any combination of STARTED, ON GOING...)

3                                              8.000                      There are 8K ids that have 3 status (any combination of STARTED, ON GOING...)

4                                              10.000                    There are 10K that have all 4 status (any combination of STARTED, ON GOING...)

                                  TOTAL   30.000

 

 

How I should produce this table?

 

Thanks in advance.🙂

 

1 ACCEPTED SOLUTION

Hi @luisccmm ,

If you want to create only one measure to calculate the count of IDs which have different distinct status, I would suggest to create a calculated table first:

Distinct table = 
VAR tab =
    ADDCOLUMNS (
        ALL ( 'Table' ),
        "distinct status",
            CALCULATE (
                DISTINCTCOUNT ( 'Table'[Status] ),
                FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
            )
    )
VAR tb =
    SUMMARIZE ( tab, [ID], [distinct status] )
RETURN
    tb

Then create this count measure and show the result in the table visual:

Count = COUNTROWS('Distinct table')

left table is the data table as a referenceleft table is the data table as a reference

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

 

Best Regards,
Community Support Team _ 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

3 REPLIES 3
Tahreem24
Super User
Super User

@luisccmm ,

Try like below DAX Measure for counting:

Count = CALCULATE(DISTINCTCOUNT('Table'[Id]),ALLEXCEPT('Table','Table'[Status]))
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hi @Tahreem24  

 

Thanks for your quick response, I have something not clear about your proposal, because ¿What I should put on Dimension?

 

There are about  4 values for  Dimension Status:

STARTED

ONGOING

FINISHED

STANDBY

 

But I am NOT looking for counting Id for each of those (STARTED, ON GOING...).

 

What I need to count is How many IDs have 1 distinct status, how many have 2 distinct status, how many have 3 distinct status.... so on.

 

 

Hi @luisccmm ,

If you want to create only one measure to calculate the count of IDs which have different distinct status, I would suggest to create a calculated table first:

Distinct table = 
VAR tab =
    ADDCOLUMNS (
        ALL ( 'Table' ),
        "distinct status",
            CALCULATE (
                DISTINCTCOUNT ( 'Table'[Status] ),
                FILTER ( ALL ( 'Table' ), 'Table'[ID] = EARLIER ( 'Table'[ID] ) )
            )
    )
VAR tb =
    SUMMARIZE ( tab, [ID], [distinct status] )
RETURN
    tb

Then create this count measure and show the result in the table visual:

Count = COUNTROWS('Distinct table')

left table is the data table as a referenceleft table is the data table as a reference

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

 

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

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.