cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RubenGA Frequent Visitor
Frequent Visitor

Improve Measure performance

Hello estimates I am developing a model that of which I analyze the sales at the currency, division, product and up to this level the measure annexed to this post works in an acceptable way however, wanting to incorporate the client level marks me insufficient memory. Please, I require your help to improve the performance of my model.

 

 

BCantActPrcAnt:=IF(HASONEVALUE(Ventas[Artículo]),
		SWITCH(TRUE(),
		OR(CALCULATE(Ventas[Prc Anterior])>0,CALCULATE(Ventas[Prc Actual])>0),
			Ventas[Qtty Actual]*Ventas[Prc Anterior],
		AND(CALCULATE(Ventas[Prc Anterior])<=0,CALCULATE(Ventas[Prc Actual])>0),
			Ventas[MXP-USD ActualV],
	BLANK()),
	BLANK()
)

Datamodel example

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Improve Measure performance

Hey,

 

try to use variables to cache values, this will avoid unnecessary evaluation like so

BCantActPrcAnt:=
var prcAnterior =  CALCULATE(Ventas[Prc Anterior])
var prcActual = CALCULATE(Ventas[Prc Actual])
return


IF(HASONEVALUE(Ventas[Artículo]),

		SWITCH(TRUE(),
		OR(prcAnterior>0,prcActual>0),
			Ventas[Qtty Actual]*prcAnterior,
		AND(prcAnterior<=0,prcActual>0),
			Ventas[MXP-USD ActualV],
	BLANK()),
	BLANK()
)

Hopefully this brings some improvement.

 

Regards,
Tom

 

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Super User
Super User

Re: Improve Measure performance

Hey,

 

try to use variables to cache values, this will avoid unnecessary evaluation like so

BCantActPrcAnt:=
var prcAnterior =  CALCULATE(Ventas[Prc Anterior])
var prcActual = CALCULATE(Ventas[Prc Actual])
return


IF(HASONEVALUE(Ventas[Artículo]),

		SWITCH(TRUE(),
		OR(prcAnterior>0,prcActual>0),
			Ventas[Qtty Actual]*prcAnterior,
		AND(prcAnterior<=0,prcActual>0),
			Ventas[MXP-USD ActualV],
	BLANK()),
	BLANK()
)

Hopefully this brings some improvement.

 

Regards,
Tom

 

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 6 members 4,224 guests
Please welcome our newest community members: