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

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.

Reply
Anonymous
Not applicable

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

I am working calculating the "Days of stock cover" for below table:

DayDate

ItemNumber

Qty running total in day date

Daily demand

Daily supply

04/06/21

301217-2

0

 

 

05/06/21

301217-2

7850.88

 

7850.88

06/06/21

301217-2

609

-7659.48

417.60

07/06/21

301217-2

609

 

 

08/06/21

301217-2

609

 

 

09/06/21

301217-2

609

 

 

10/06/21

301217-2

0

-609

 

Using following measure where the sintax looks correct

But I am getting following error: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value

 

Days of Cover 2 =

VAR s = [QTY running total in DayDate]

VAR w = FILTER('dwh view_Date','dwh view_Date'[DayDate])

VAR t =

    FILTER ( 'dwh view_Date','dwh view_Date'[DayDate] > w )

VAR t2 =

    ADDCOLUMNS (

        t,

        "total", SUMX (

            FILTER ( t, 'dwh view_Date'[DayDate] <= EARLIER ('dwh view_Date'[DayDate])),

            [Daily Demand]

        )

    )

RETURN

    IF (

        COUNTROWS ( FILTER ( t2, [total] >= s ) )

            > 0,

        COUNTROWS ( FILTER ( t2, [total] < s ) )

            + DIVIDE (

                s

                    - MAXX ( TOPN ( 1, FILTER ( t2, [total] < s ), 'dwh view_Date'[DayDate], DESC ), [total] ),

                MAXX (

                    TOPN ( 1, FILTER ( t2, [total] >= s ), 'dwh view_Date'[DayDate], ASC ),

                    [Daily Demand]

                )

            )

    )

 

- DayDate field is from table: dwh view_Date

- ItemNumber field is from table:  dwh view_dim_ReleasedProduct

- QTY fields are all measures calculated within table DXCReqTransStaging as follows:

 

QTY running total in DayDate =

CALCULATE(

    SUM('DXCReqTransStaging'[QTY]),

    FILTER(

        ALLSELECTED('dwh view_Date'[DayDate]),

        ISONORAFTER('dwh view_Date'[DayDate], MAX('dwh view_Date'[DayDate]), DESC)

    )

)

 

Daily Demand = CALCULATE(SUM(DXCReqTransStaging[QTY]),DXCReqTransStaging[QTY]<0)

Daily Supply = CALCULATE(SUM(DXCReqTransStaging[QTY]),DXCReqTransStaging[QTY]>0)

 

Star schema summary for the tables is:

- “dwh view_Date” is linked to “DXCReqTrabnsStaging” with relation "one to many"

- “dwh view_dim_ReleaseProduct” is linked to to “DXCReqTrabnsStaging” with relation "one to many"

 

Could someone help, please?

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

Could you please review the part of your measure [Days of Cover 2] with red circle, it seems not good... Is the table w used for extracting the data from the field [DayDate]? It will return multiple values....

yingyinr_1-1624241336605.png

In addition, please review the solution in the following link which have similar problem with yours. Hope they can help you resolve the problem.

DAX Error: The Expression Refers to Multiple Columns. Multiple Columns Cannot Be Converted to a Scalar Value.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

Could you please review the part of your measure [Days of Cover 2] with red circle, it seems not good... Is the table w used for extracting the data from the field [DayDate]? It will return multiple values....

yingyinr_1-1624241336605.png

In addition, please review the solution in the following link which have similar problem with yours. Hope they can help you resolve the problem.

DAX Error: The Expression Refers to Multiple Columns. Multiple Columns Cannot Be Converted to a Scalar Value.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.