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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

Optimize Measurement

Hello everyone

I am trying to generate a measure such that it tells me the number of materials that make up the 80% of sales given a segment for all customers, then when filter by customer I indicate how many materials that customer has assigned are within the 8020 materials previously calculated. I have found a solution but the measurement takes a long time to calculate, so I try to optimize it. The measure is:

Measure =
VAR Amount Earned = CALCULATE(Measures[Measure Amount Earned], ALLSELECTED(Billing[Segment]),ALLSELECTED(Billing[Customer]))
VAR Table1 = CALCULATETABLE(FILTER(VALUES(Facturacion[Material]),DIVIDE(SUMX(TOPN(Measures[Measure Rank],CALCULATETABLE(VALUES(Facturacion[Material]),ALLSELECTED(Facturacion[Material])),[Measure Amount Earned]),Measures[Measure Amount Earned]),IF(NOT(ISBLANK(AmountEarned)),CALCULATE([Measure Amount Earned],ALLSELECTED(Invoice[Material]))))<0.8),ALL(Billing[Customer]))
VAR MedidaNumeroMateriales8020_Total = COUNTROWS(Table 1)
VAR Table2 = FILTER(CALCULATETABLE(FILTER(VALUES(Facturacion[Material]),DIVIDE(SUMX(TOPN(Measures[Measure Rank],CALCULATETABLE(VALUES(Facturacion[Material]),ALLSELECTED(Facturacion[Material])),[Measure Amount Earned]),Measures[Measure Amount Earned]),IF(NOT(ISBLANK(AmountEarned)),CALCULATE([Measure Amount Earned],ALLSELECTED(Invoice[Material]))))<0.8),ALL(Billing[Customer]),Measures[Measure Amount Earned]>0)
VAR MedidaNumeroMateriales8020_Cliente = COUNTROWS(Table2)
RETURN
DIVIDE(MedidaNumeroMateriales8020_Cliente,MedidaNumeroMateriales8020_Total)

where we only take a measure called Rank Measure that was calculated previously defined as:

Measure Rank = IF(HASONEVALUE(Billing[Material]),RANKX(ALL(Billing[Material]),Measures[Measure Amount Earned]),BLANK())

as I optimize the measure since when inegrar everything, that is, placing the rank measure within the measure of the calculation gives me different values or if there is any different way to achieve that the measure was calculated faster

1 REPLY 1
foodd
Community Champion
Community Champion

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.