Forum Discussion

unclejemima's avatar
unclejemima
Post Patron
8 years ago
Solved

Function expects a column name as argument number 4? Help :-)

I'm trying to use this code but getting the error "Fuction Expects ADDCOLUMNS expects a column name as argument number 4.""

 

DateTime = 
ADDCOLUMNS (
    CROSSJOIN (
        CALENDAR(MIN(Invoice[NvDate]),max(Invoice[NvDate])),
        UNION (
            ROW ( "Time", TIME ( 1, 0, 0 ) ),
            ROW ( "Time", TIME ( 2, 0, 0 ) ),
            ROW ( "Time", TIME ( 3, 0, 0 ) ),
            ROW ( "Time", TIME ( 4, 0, 0 ) ),
            ROW ( "Time", TIME ( 5, 0, 0 ) ),
            ROW ( "Time", TIME ( 6, 0, 0 ) ),
            ROW ( "Time", TIME ( 7, 0, 0 ) ),
            ROW ( "Time", TIME ( 9, 0, 0 ) ),
            ROW ( "Time", TIME ( 10, 0, 0 ) ),
            ROW ( "Time", TIME ( 11, 0, 0 ) ),
            ROW ( "Time", TIME ( 12, 0, 0 ) ),
            ROW ( "Time", TIME ( 13, 0, 0 ) ),
            ROW ( "Time", TIME ( 14, 0, 0 ) ),
            ROW ( "Time", TIME ( 15, 0, 0 ) ),
            ROW ( "Time", TIME ( 16, 0, 0 ) ),
            ROW ( "Time", TIME ( 17, 0, 0 ) ),
            ROW ( "Time", TIME ( 18, 0, 0 ) ),
            ROW ( "Time", TIME ( 19, 0, 0 ) ),
            ROW ( "Time", TIME ( 20, 0, 0 ) ),
            ROW ( "Time", TIME ( 21, 0, 0 ) ),
            ROW ( "Time", TIME ( 22, 0, 0 ) ),
            ROW ( "Time", TIME ( 23, 0, 0 ) ),
            ROW ( "Time", TIME ( 24, 0, 0 ) )
        )
    ),
    "DateTime", [Date] + [Time],)
  • Hi unclejemima

     

    Yes... AddColumn is a function which returns a Table......It cannot be used in Calculated Columns and Measures....Directly..

     

    However you can use this code as a CALCULATED TABLE
    So if you go to Modelling Tab>>New Table and paste this code...you will get an entirely new Table in your Model

     

     

     

9 Replies

    • unclejemima's avatar
      unclejemima
      Post Patron

       

       

      Sorry doing so now I get a "The expression refers to multiple columns.  Multiple columns cannot be converted to a scalar value 

      • Zubair_Muhammad's avatar
        Zubair_Muhammad
        Community Champion

        Hi unclejemima

         

        This is a calculated table right???

         

        I hope you are not using it as a MEASURE or Calculated Column

         

        When I use it as a calculated table... it works perfectly

         

        Go to Modelling Tab>>>NEW TABLE and then use this formula

         

        DateTime =
        ADDCOLUMNS (
            CROSSJOIN (
                CALENDAR ( MIN ( Invoice[NvDate] ), MAX ( Invoice[NvDate] ) ),
                UNION (
                    ROW ( "Time", TIME ( 1, 0, 0 ) ),
                    ROW ( "Time", TIME ( 2, 0, 0 ) ),
                    ROW ( "Time", TIME ( 3, 0, 0 ) ),
                    ROW ( "Time", TIME ( 4, 0, 0 ) ),
                    ROW ( "Time", TIME ( 5, 0, 0 ) ),
                    ROW ( "Time", TIME ( 6, 0, 0 ) ),
                    ROW ( "Time", TIME ( 7, 0, 0 ) ),
                    ROW ( "Time", TIME ( 9, 0, 0 ) ),
                    ROW ( "Time", TIME ( 10, 0, 0 ) ),
                    ROW ( "Time", TIME ( 11, 0, 0 ) ),
                    ROW ( "Time", TIME ( 12, 0, 0 ) ),
                    ROW ( "Time", TIME ( 13, 0, 0 ) ),
                    ROW ( "Time", TIME ( 14, 0, 0 ) ),
                    ROW ( "Time", TIME ( 15, 0, 0 ) ),
                    ROW ( "Time", TIME ( 16, 0, 0 ) ),
                    ROW ( "Time", TIME ( 17, 0, 0 ) ),
                    ROW ( "Time", TIME ( 18, 0, 0 ) ),
                    ROW ( "Time", TIME ( 19, 0, 0 ) ),
                    ROW ( "Time", TIME ( 20, 0, 0 ) ),
                    ROW ( "Time", TIME ( 21, 0, 0 ) ),
                    ROW ( "Time", TIME ( 22, 0, 0 ) ),
                    ROW ( "Time", TIME ( 23, 0, 0 ) ),
                    ROW ( "Time", TIME ( 24, 0, 0 ) )
                )
            ),
            "DateTime", [Date] + [Time]
        )