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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
amilkarigi
Helper I
Helper I

Measure Misunderstanding

Hi, I'm trying to create a measure that calculates my top 10 buyers/customers who have bought an specific product (my top product from an specific year) which is calculated with another measure called Mas Vendidos, so here is my code:

Top Clientes = 
VAR
    Prod = [Mas Vendido]
VAR
    Cliente = VALUES(Clientes[CompanyName])
RETURN
    CALCULATE([Ventas Total];
        FILTER(Cliente;
            RANKX(ALL(Clientes[CompanyName]); [Ventas Total];;DESC) <= 10); Productos[ProductName] = Prod)

The thing is it returns an error:

 

"...a table of multiple values was supplied where a single value was expected"

 

And if I delete the Prod variable and change it at the end with "Halter Dress" (my top product) then it is correct.

Top Clientes P = 
VAR
    Cliente = VALUES(Clientes[CompanyName])
RETURN
    CALCULATE([Ventas Total];
        FILTER(Cliente;
            RANKX(ALL(Clientes[CompanyName]); [Ventas Total];;DESC) <= 10); Productos[ProductName] = "Halter Dress")


PSD: Mas Vendidos Code:

Mas Vendido = TOPN(1; ALL(Productos[ProductName]); [Ventas Total];DESC)

Error (with Prod variable)Error (with Prod variable)What I want it to show (with "Halter Dress" instead of Prod variable)What I want it to show (with "Halter Dress" instead of Prod variable)

 

1 ACCEPTED SOLUTION
mattbrice
Solution Sage
Solution Sage

I believe the error is because Dax engine has detected that your TOPN function in "Mas Vendido" could return more than one value (in a tie situation)  So I think you eithe either need to test if "Prod" variable has more than one row and respond accordingly, or perhaps wrap it in a FIRSTNONBLANK call like so:

 

Mas Vendido = FIRSTNONBLANK ( TOPN(1; ALL(Productos[ProductName]); [Ventas Total];DESC), 1 )

View solution in original post

2 REPLIES 2
mattbrice
Solution Sage
Solution Sage

I believe the error is because Dax engine has detected that your TOPN function in "Mas Vendido" could return more than one value (in a tie situation)  So I think you eithe either need to test if "Prod" variable has more than one row and respond accordingly, or perhaps wrap it in a FIRSTNONBLANK call like so:

 

Mas Vendido = FIRSTNONBLANK ( TOPN(1; ALL(Productos[ProductName]); [Ventas Total];DESC), 1 )

Thanks a lot. It solved my problem just how i wanted it.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.