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

measure to count number of materials in table - power bi desktop

Hi, if the below is my Power BI desktop screen with table created, 

What measure can I use to calculate that there are 4 of the same materials in the table? showing next to each line as below.

The count column must show the result as 4 as below.

 

Material Number   Count

39055xAJRE4
39055xAJRE4
39055xAJRE4
39055xAJRE4

 

Thanks in advance 🙂

Table name  "All Orders"

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

I did a test, the reference is as follows:

Table 2 =
SUMMARIZE (
    'Table',
    'Table'[Material Number   Count],
    "Count",
        CALCULATE (
            COUNT ( 'Table'[Material Number   Count] ),
            FILTER (
                ALL ( 'Table' ),
                MAX ( 'Table'[Material Number   Count] ) = 'Table'[Material Number   Count]
            )
        )
)

vhenrykmstf_0-1625127436690.pngvhenrykmstf_1-1625127450324.png

 

Best Regards,
Henry

 

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

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

I did a test, please try the following formula:

M =
CALCULATE (
    COUNTROWS ( 'All Orders' ),
    FILTER ( ALL ( 'All Orders' ), 'All Orders'[Material Number ] = "39055xAJRE" )
)
table =
SUMMARIZE (
    'All Orders',
    'All Orders'[Index],
    "M",
        CALCULATE (
            MAX ( 'All Orders'[Material Number ] ),
            FILTER ( ALL ( 'All Orders' ), 'All Orders'[Material Number ] = "39055xAJRE" )
        ),
    "C", [Measure]
)


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.

Best Regards,
Henry

 

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

Anonymous
Not applicable

Hi, Thank you, however, I don't only have one material to count, "39055xAJRE", but a list of materials.

Is there a solution for that?

Hi @Anonymous ,

 

I did a test, the reference is as follows:

Table 2 =
SUMMARIZE (
    'Table',
    'Table'[Material Number   Count],
    "Count",
        CALCULATE (
            COUNT ( 'Table'[Material Number   Count] ),
            FILTER (
                ALL ( 'Table' ),
                MAX ( 'Table'[Material Number   Count] ) = 'Table'[Material Number   Count]
            )
        )
)

vhenrykmstf_0-1625127436690.pngvhenrykmstf_1-1625127450324.png

 

Best Regards,
Henry

 

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

 

amitchandak
Super User
Super User

@Anonymous , try a measure like 

calculate(count(Table[material Number]), allexcept(Table, Table[material Number]))

Anonymous
Not applicable

@amitchandak   Hi, unfortunately, this did not work.  I have many of this material in my source data, but only 4 in my table data. I need to summarize so that the count only shows that of the material on the summarized table.

Regards

Vicky

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.