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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Performance Issue Advice

Hi guys!

 

I am suffering with a performance issue for a measure.

It is derived from several others, so I'll paste all the ones that are calculated for the last one to exist.

All the previous are not affecting the performance when brought in a table (for instance).

 

Do you have any advices to save processing, maybe using different syntaxes...

 

This is what I did to calculate the average use for the next 30 days of every itemThis is what I did to calculate the average use for the next 30 days of every itemThen this is what I did to find out the target stock value for each oneThen this is what I did to find out the target stock value for each oneI then do a SUMX against the unit valuesI then do a SUMX against the unit valuesThis is how I calculate what I current have in StockThis is how I calculate what I current have in StockAnd finally this is the Measure that is causing the performance impact, when I have to calculate the Excess Stock existent based on all the previous onesAnd finally this is the Measure that is causing the performance impact, when I have to calculate the Excess Stock existent based on all the previous ones

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@Anonymous,

You can use variable to avoid double calculation in your measure:

Excess Stock =
VAR result = [Valid Stock Value] - [TargetStockValue] - [No Future Use]
RETURN
    IF ( result < 0, 0, result )

View solution in original post

Anonymous
Not applicable

@Anonymous, 

Same principle applies. You want to avoid repeating measure because it calculates every time you mention it. Use variable so the result is stored in the memory

Stock OK =
VAR validStock = [Valid Stock Value]
VAR targetStock = [TargetStockValue]
RETURN
    SWITCH ( TRUE (); validStock >= targetStock; targetStock; validStock )

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@Anonymous,

You can use variable to avoid double calculation in your measure:

Excess Stock =
VAR result = [Valid Stock Value] - [TargetStockValue] - [No Future Use]
RETURN
    IF ( result < 0, 0, result )
Anonymous
Not applicable

@Anonymous 
This one is still a bit slow, though... any ideas about it?

Stock OK = SWITCH(TRUE();
[Valid Stock Value]>=[TargetStockValue];[TargetStockValue];
[Valid Stock Value])
Anonymous
Not applicable

@Anonymous, 

Same principle applies. You want to avoid repeating measure because it calculates every time you mention it. Use variable so the result is stored in the memory

Stock OK =
VAR validStock = [Valid Stock Value]
VAR targetStock = [TargetStockValue]
RETURN
    SWITCH ( TRUE (); validStock >= targetStock; targetStock; validStock )

 

 

Anonymous
Not applicable

@Anonymous 


@Anonymous wrote:

@Anonymous,

You can use variable to avoid double calculation in your measure:

Excess Stock =
VAR result = [Valid Stock Value] - [TargetStockValue] - [No Future Use]
RETURN
    IF ( result < 0, 0, result )


Awesome! This reduced the calculation time from 4 minutes to 10 secs. Thanks!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors