Hi Shila ,
Solution Amit provided should work .
Though, we can look at optimizing this calculation at backend unless the measure itself a derived variable with extended calculation syntax based on database .
Ex : In universe try to include where clause for the measure with Prompt
or If it's BEx , try to restrict the key figure with variable .