Forum Discussion

Chris2016's avatar
Chris2016
Resolver I
3 years ago
Solved

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    

 


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.

 

  • Chris2016 

    Please try

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

4 Replies

  • 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!

  • tamerj1's avatar
    tamerj1
    Community Champion

    Chris2016 

    Please try

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