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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
NPC
Helper I
Helper I

Count Based on Two Colums

Hello,

 

Help please! I have a table that looks like this

 

CustomerIDEvent IDCount of Events
124451001 
124451002 
124451003 
124451003 

 

I need to fill the "Count Of Events" column in this case with 3 for this customer ID because there were three unique events. The last one is a duplicate and I don't want to count it. 

 

I was using this formular until I realized that it  counts these as 4 Events, not 3. 

 

OutageCount =
CALCULATE(
    COUNTROWS(Outages),
    FILTER(Outages, Outages[CustomerID] = EARLIER(Outages[CustomerID]))
)

 

Any suggestions on how I can modfiy the formular above? A completly different formular is also welcome.

 

Thank you!

1 ACCEPTED SOLUTION
Prateek97
Resolver III
Resolver III

Hi @NPC ,

 

You can simply do Disttinctcount here instead of COUNTROWS.

 

OutageCount =
CALCULATE(
    DISTINCTCOUNT(Outages[EventID]),
    FILTER(Outages, Outages[CustomerID] = EARLIER(Outages[CustomerID]))
)

 

Please mark as solution, if it works.

View solution in original post

4 REPLIES 4
NPC
Helper I
Helper I

Hi @v-cgao-msft, it works with a test dataset. I guess it comes down to the size of my dataset.

 

NPC_1-1694127388725.png

 

 

Prateek97
Resolver III
Resolver III

Hi @NPC ,

 

You can simply do Disttinctcount here instead of COUNTROWS.

 

OutageCount =
CALCULATE(
    DISTINCTCOUNT(Outages[EventID]),
    FILTER(Outages, Outages[CustomerID] = EARLIER(Outages[CustomerID]))
)

 

Please mark as solution, if it works.

Thank you @Prateek97. For some reason I'm getting the "Working on it" message when I try to add the column and I get stuck there forever. Not sure if its because the table is very big. 

Hi @NPC ,

It's a very simple calculation that shouldn't consume too many resources.🤔

Please try:

1. Update Power BI: Ensure you're using the latest version of Power BI Desktop.
Download Power BI Desktop from Official Microsoft Download Center

2. Check for large model: If you're working with a large model, it might take longer to process. Consider optimizing your data model or filtering the data before adding the column.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.