Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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)
Solved! Go to Solution.
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 )
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
93 | |
77 | |
65 | |
53 |
User | Count |
---|---|
147 | |
106 | |
104 | |
87 | |
61 |