Forum Discussion

Coolpearl's avatar
Coolpearl
Regular Visitor
1 year ago

Alternative to countrows-filter-values calculation

I have below calculations in some fields which take time to run. I am looking for alternative for same to improve performance. 
measure = 

if( 

     countrows( filter( values( 'emptable'[type])' , 'emptable'[type] = "retired" ) )  > 0,

         Calculate( [measure_counted] , 'emptable'[type] = "retired" ), 0 

)

 

in above, 'filter' is affecting performance. 

Plz suggest alternative if any. Thanks.

6 Replies

  • Deku's avatar
    Deku
    Super User

    This might be better

     

    If(

    "Retired" in values( 'emptable'[type])',

    Calculate(

    [measure_counted] ,

    'emptable'[type] = "retired"

    ), 0

    )

     

    If you know the [measure_counted] will not return a result if filter by retired, and there are no retired

     

    Var result = Calculate(

    [measure_counted] ,

    'emptable'[type] = "retired"

    )

    Return 

    If( isblank( result ), result, 0)

  • Coolpearl , Try like

     

    Calculate( [measure_counted] , filter( 'emptable', 'emptable'[type] = "retired" )) +0

  • Hi,

    Try this

    Measure = coalesce(Calculate( [measure_counted] , 'emptable'[type] = "retired" ),0)

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Coolpearl 
    Thank you for reaching out microsoft fabric community forum.

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Coolpearl 
    I wanted to check if you had the opportunity to review the information provided by Ashish_Mathur , amitchandak  and Deku . Please feel free to contact us if you have any further questions. If their response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Coolpearl 
    I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
    Thank you.