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

CountIf in PB

Hello, i have a database just like this one in Excel

Postigo_0-1598227043265.png

In this situation i can use COUNTIF in the OrderId column, but in power bi i cant figure out how to translate this to a calculate funtion or even in M language, is there any way to do something like this "CountIf column"?



Thanks


PowerBI File 





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

Hi @Anonymous ,

According to my understanding, you want to calculate the count per OrderID, right?

 

You could use the following formula:

CountPerOrderId =
CALCULATE ( COUNTROWS ( 'CountIf' ), ALLEXCEPT ( CountIf, CountIf[OrderId] ) )

My visualization looks like this:

 8.24.1.1.jpg

For more useful information ,you could refer to:  https://goodly.co.in/countif-power-bi-dax/ 

 

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

View solution in original post

4 REPLIES 4
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

According to my understanding, you want to calculate the count per OrderID, right?

 

You could use the following formula:

CountPerOrderId =
CALCULATE ( COUNTROWS ( 'CountIf' ), ALLEXCEPT ( CountIf, CountIf[OrderId] ) )

My visualization looks like this:

 8.24.1.1.jpg

For more useful information ,you could refer to:  https://goodly.co.in/countif-power-bi-dax/ 

 

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

mahoneypat
Employee
Employee

You can use this expression in a measure to get the count of rows with the same OrderID

 

Count Same ID = CALCULATE(COUNTROWS(Table), ALLEXCEPT(Table, Table[OrderId]))

 

Use it in a table visual with the OrderId column.  Replace Table with the actual table name.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Greg_Deckler
Super User
Super User

@Anonymous - According to Excel to DAX Translation: https://community.powerbi.com/t5/Community-Blog/Excel-to-DAX-Translation/ba-p/1060991

 

COUNTIF is here: https://community.powerbi.com/t5/Community-Blog/CO-CU-Excel-to-DAX-Translation/ba-p/1080018#M2077

 

And is:

COUNTX(FILTER(...)...) or CALCULATE(COUNT(),FILTER(...))


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Can you give me an example of what you want the conditions to be? 

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.