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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Chris2016
Resolver I
Resolver I

Optimizing performance when using time comparison

Hello,

 

I have a large dataset where some of the data looks like this:

NameTestActivityDateStartedDateCompletedPercCompleteKey_TestCompleteDate_CompletedIndividual_TestCompleteUpToLastMonth_TestCompleteUpToLastMonth2
Ax103/02/2022 25%A-x    
Ax203/02/2022 25%A-x    
Ax303/03/202204/04/202225%A-x    
Ax406/03/2022 25%A-x    
Ay104/02/202204/02/2022100%A-y04/05/2022A11
Ay204/02/202204/02/2022100%A-y04/05/2022A11
Ay304/05/202204/05/2022100%A-y04/05/2022A11
Bz110/02/2022 60%B-z    
Bz210/02/202210/02/202260%B-z    
Bz310/02/202210/02/202260%B-z    
Bz410/03/202210/13/202260%B-z    
Bz510/05/2022 60%B-z    
Cx110/10/202210/11/2022100%C-x10/13/2022C11
Cx210/12/202210/12/2022100%C-x10/13/2022C11
Cx310/12/202210/12/2022100%C-x10/13/2022C11
Cx410/12/202210/13/2022100%C-x10/13/2022C11
Cy110/13/202210/13/2022100%C-y03/29/2023C  
Cy210/13/202210/13/2022100%C-y03/29/2023C  
Cy310/29/202203/29/2023100%C-y03/29/2023C  
Dz101/12/202301/12/202340%D-z    
Dz201/12/202301/12/202340%D-z    
Dz302/01/2023 40%D-z    
Dz402/01/2023 40%D-z    
Dz502/01/2023 40%D-z    

 

Chris2016_1-1680186958944.png


Where
Columns:

PercComplete = DIVIDE(CALCULATE(COUNTA('Table'[DateCompleted]), ALLEXCEPT('Table','Table'[Key])), CALCULATE(COUNTA('Table'[Activity]), ALLEXCEPT('Table','Table'[Key])), 0)

 

_CompletedIndividual = IF([PercComplete]=1, [Name], BLANK())
_TestCompleteDate = IF([PercComplete]=1, CALCULATE(MAX([DateCompleted]), ALLEXCEPT('Table','Table'[Key])))
_TestCompleteUpToLastMonth = IF([_TestCompleteDate]<=TODAY()-30 && [_CompletedIndividual]<>BLANK(),1)
& measure
TestCompleteIndividuals = CALCULATE(DISTINCTCOUNT('Table'[Name]),FILTER('Table','Table'[_TestCompleteUpToLastMonth]=1))

or column:
_TestCompleteUpToLastMonth2 = 
var maxcompldate =CALCULATE(MAX([_TestCompleteDate]), ALLEXCEPT('Table','Table'[Key]))
return IF(maxcompldate<=TODAY()-30 && [_CompletedIndividual]<>BLANK(),1)
& measure:
TestCompleteIndividuals2 = CALCULATE(DISTINCTCOUNT('Table'[Name]),FILTER('Table','Table'[_TestCompleteUpToLastMonth2]=1))

What I am trying to achieve is calculate how many "Name"-s have completed all the "Activities" of a "Test" up until 30 days ago (measures TestCompleteIndividuals and TestCompleteIndividuals2).
A basic calculation of who completed all the activities is working just fine with the report visuals, but when I add the TestCompleteIndividuals and TestCompleteIndividuals2 measures working with [_TestCompleteDate]<=TODAY()-30 or maxcompldate<=TODAY()-30, the visuals that contain any of these measures take so long to load, they sometimes crash.

Is there a way to calculate how many "Name"-s have passed all the activities in a test up until a month ago that will not burden the report performance?

Many thanks for any input on the matter.

 

1 ACCEPTED SOLUTION
tamerj1
Community Champion
Community Champion

@Chris2016 

Please try

TestCompleteIndividuals =
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
FILTER ( 'Table', 'Table'[_TestCompleteUpToLastMonth] = 1 ),
"@Name", 'Table'[Name]
)
)
)

View solution in original post

4 REPLIES 4
Chris2016
Resolver I
Resolver I

Thanks a lot for your help, Tamer, this is great. The visuals no longer have issues loading.
Any idea why this measures has performance issues in the given context as opposed to your approach?

TestCompleteIndividuals = CALCULATE(DISTINCTCOUNT('Table'[Name]),FILTER('Table','Table'[_TestCompleteUpToLastMonth]=1))

 Thanks, and best regards!

"... counting unique values in complex reports can still create performance issues. The main reason for this is that DISTINCTCOUNT is a non-additive aggregation that must be computed for every cell in the report. Understanding the behavior of this aggregation can explain why other equivalent expressions that are slower in theory, can provide better performance in specific reports."
This is great, thanks, @tamerj1 !

tamerj1
Community Champion
Community Champion

@Chris2016 

Please try

TestCompleteIndividuals =
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
FILTER ( 'Table', 'Table'[_TestCompleteUpToLastMonth] = 1 ),
"@Name", 'Table'[Name]
)
)
)

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.