Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

I have Table with Should Cost, Should Cost Date, NewSupplier. I need to create a visualization Table, where it should show selected supplier values + values from Blank supplier where condition is that for blank supplier it should take the values, after maximum date for selected supplier for next 6 months. e.g. I ahve selected supplier from slicer like "ABC" and max date is 10-04-2023, then in the visualization table, it should reflect the values fro blank supplier next 6 months values from 10-04-2023.
I tired creating simple DAX, DAX Table and all. however it is not working. can some one help me here please. Please let me know if you need any thing from my end. Thanks! 
 
Filtered_ShouldCost =
VAR SelectedSupplier = SELECTEDVALUE(SupplierSlicer_01[NewSupplier])
VAR MaxDateForSupplier =
    CALCULATE(
        MAX('genai should_cost_data'[should_cost]),
        FILTER(
            ALL('genai should_cost_data'),
            'genai should_cost_data'[Supplier] = SelectedSupplier
        )
    )
VAR MinDate = MaxDateForSupplier
VAR MaxDate = EDATE(MaxDateForSupplier, 6)

VAR SupplierRows =
    FILTER(
        ALL('genai should_cost_data'),
        'genai should_cost_data'[Supplier] = SelectedSupplier
    )

VAR BlankRows =
    FILTER(
        ALL('genai should_cost_data'),
        'genai should_cost_data'[new_measure] = "BlankSupplier"
        && 'genai should_cost_data'[should_cost_date] >= MinDate
        && 'genai should_cost_data'[should_cost_date] <= MaxDate
    )

RETURN
IF(
    ISBLANK(SelectedSupplier),
    FILTER('genai should_cost_data', FALSE),
    IF(
        SelectedSupplier = "BlankSupplier",
        FILTER(
            ALL('genai should_cost_data'),
            'genai should_cost_data'[NewSupplier] = "BlankSupplier"
        ),
        UNION(SupplierRows, BlankRows)
    )
)

19 Replies