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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
maryjanesmith
Helper I
Helper I

Help Optimizing Calculated Column & Measure: count records based on columns

Hi
I need to count the records that have the same client and the same ticket but different open dates which means I am only interested in cases of clients that reopen the ticket for the same reason. In the case below the count should be 12.

 

idticket idcliet Date

1200112/07/2021
1200112/07/2021
1200113/07/2021
1200114/07/2021
1200113/07/2021
1200112/07/2021
1200118/07/2021
1200119/08/2021
1200604/12/2021
1200605/12/2021
1210006/11/2021
1302014/07/2021
1400713/07/2021
1401301/07/2021
2205005/08/2021


I wrote this calculated column:

 

var valorActualConta='Table'[idclient]
var valorActualOcorrencia='Table'[idticket]
var valorActualTempo='Table'[Date_Time]
return calculate(DISTINCTCOUNT('Table'[Date_Time] ),FILTER(ALL('Table'),'Table'[idclient] = valorActualConta && 'Table'[idticket] = valorActualOcorrencia ))

 

and then I wrote a measure to sum all the cases:


sumx(SUMMARIZE('Table','Table'[idclient],'Table'[idticket],"max",max('Table'[Reincidências])),[max])

 

The file is here https://1drv.ms/u/s!AuMLcKZkL7PFgkY3qjc2GJ35giM2?e=focqp7

 

The problem is that the real table has almost 2 million rows and the calculated column is waiting...until now.

Can you help, please?

Thank you

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

Can you see if this works any better as the calculated column?

Reincidências = 
CALCULATE(
    DISTINCTCOUNT('Table'[Date_Time] ),
    ALLEXCEPT ( 'Table', 'Table'[idclient], 'Table'[idticket] )
)

 


If not I'll think about a more fundamental change!



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

2 REPLIES 2
maryjanesmith
Helper I
Helper I

Thank you, yes it is much better!

bcdobbs
Community Champion
Community Champion

Can you see if this works any better as the calculated column?

Reincidências = 
CALCULATE(
    DISTINCTCOUNT('Table'[Date_Time] ),
    ALLEXCEPT ( 'Table', 'Table'[idclient], 'Table'[idticket] )
)

 


If not I'll think about a more fundamental change!



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.