How to fix error in DAX measues “a table of multiple values was supplied where a single…
- User
How to fix error in DAX measues “a table of multiple values was supplied where a single value was expected”?
- Assistant
When encountering the error message "a table of multiple values was supplied where a single value was expected," it indicates that a DAX measure is attempting to work with multiple values instead of a single value.
To fix this error, you need to review and adjust the DAX measure to ensure it is returning a single value. Here are some steps to follow:
-
Identify the problematic DAX measure: Determine which measure is causing the error message. Review the formulas and calculations involved.
-
- User
If there are columns Date, Customer, SKU, Final. How to write DAX expression to assign the value in Final column to the second and next rows sorted by Date for each combination of Customer and SKU?
- Assistant
To assign the value in the Final column to the second and subsequent rows sorted by Date for each combination of Customer and SKU, you can use the following DAX expression:
Final Value = VAR CustomerSKU = CONCATENATE(Customer, "-", SKU) VAR SortedTable = ADDCOLUMNS ( SUMMARIZE( FILTER( ALL('Table'); [Customer] = EARLIER([Customer]) && [SKU] = EARLIER([SKU]) ); [Date]; "FinalRow"; RANKX ( FILTER( ALL('Table'); [Customer] = EARLIER([Customer]) && [SKU] = EARLIER([SKU]) ); [Date] ) ); "CustomerSKU"; CustomerSKU ) RETURN IF ( RANKX ( SortedTable; [Date] ) > 1; LOOKUPVALUE( 'Table'[Final]; 'Table'[Customer]; VALUES('Table'[Customer]); 'Table'[SKU]; VALUES('Table'[SKU]); 'Table'[Date]; VALUES(SortedTable[FinalRow]) - 1 ); 'Table'[Final] )