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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
RubenIdx
Helper I
Helper I

Optimizing Hasonevalue()

Hi Everybody, I want to know if is it possible to optimize Hasonevalue() in powerpivot I've created a model that runs some slowly and this is one of the principal reasons, I use many verifications Hasonevalue necessarly my fact table is around 200,000 lines and Dax Studio indicates that most of the measures involving hasonevalue() are which consume most of the runing time. 

In this example I want to do a calculation only for subtotal/total row when the table shows Items(products) it has to show blank() value.

 

Thanks in advance!

Here my code:

 

 

MixEffect:= IF (
HASONEVALUE ( Sales[Item] ),
0,
DIVIDE ( Sales[FxMixV], [Last Sale], 0 )
)

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @RubenIdx,

According to your formula, it seems like you nested other formulas in the current measure. Did you nested an iterator function? Can you please share formulas that you used to help us clarify your scenario?

Optimizing nested iterators in DAX 

In addition, dax functions in excel are different from power bi dax function, it will be help if you share some dummy data to test.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

HI @RubenIdx,

According to your formula, it seems like you nested other formulas in the current measure. Did you nested an iterator function? Can you please share formulas that you used to help us clarify your scenario?

Optimizing nested iterators in DAX 

In addition, dax functions in excel are different from power bi dax function, it will be help if you share some dummy data to test.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Hi Xiaoxin Sheng!

 

It was very useful the reference you gave me this one made me investigate more about nested queries in DAX and indeed this significantly improved the performance of my model.

 

At the beginning I used this measure to calculate the amount of sales and a similar measure to calculate the total units.

Venta Actual:=CALCULATE([ZVBase],
			Periodos[Año]=2020,
			ALLSELECTED(Periodos[Mes])
			)

 

Performance improved when I applied summarize in these calculations.

Venta Actual:=CALCULATE(
sum(ventas[VBase]),
FILTER(
ADDCOLUMNS(
SUMMARIZE(Ventas,Periodos[Año],Productos[Producto]),
"Ventas Act",Ventas[zventa]
),
Periodos[Año]=IF ( HASONEVALUE ( Selector1[Actual] ), VALUES ( Selector1[Actual] ), 2020 ))
,ALLSELECTED(Periodos[Mes]))

 

 

I would be very grateful if you could give me your opinion on the way I proposed my measure.

 

PaulDBrown
Community Champion
Community Champion

@RubenIdx 

 

Is the function ISINSCOPE on Power Pivot? If so, try using that instead (same syntax).

Please let us know if there is a difference (I'm curious!)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi! I have reviewed and this function is not available in powerpivot. Thanks

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

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.