cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amilkarigi Regular Visitor
Regular Visitor

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)

Captura.PNGError (with Prod variable)Captura1.PNGWhat I want it to show (with "Halter Dress" instead of Prod variable)

 

1 ACCEPTED SOLUTION

Accepted Solutions
mattbrice Senior Member
Senior Member

Re: Measure Misunderstanding

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 Senior Member
Senior Member

Re: Measure Misunderstanding

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

amilkarigi Regular Visitor
Regular Visitor

Re: Measure Misunderstanding

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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 53 members 1,139 guests
Please welcome our newest community members: