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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
andersonm
Regular Visitor

Sum values of a column in a table assigned to a variable

Hi guys!

 

I need some help with this.

 

I am trying to build a function that allows me to assign a given number to a day of the week and then add those amounts between two dates that can be selected according to another table context.

 

I have managed to make this filter, and identify in a single column the values to be summed.

VAR HORASINTERM =
SELECTCOLUMNS (
    ADDCOLUMNS (
        FILTER (
            'Calendario académico',
            'Calendario académico'[fecha] > DATE ( 2022, 04, 01 )
                && 'Calendario académico'[fecha] < TODAY ()
        ),
        "HorasInterm",
            IF (
                'Calendario académico'[dia_lab] = "True",
                IF ( 'Calendario académico'[dia_semana] = "6", 10, 12 ),
                0
            )
    ),
    "COLUMNAF[HorasInterm2]", [HorasInterm]
)

And this is the ouput

andersonm_0-1649261387696.png

 

So, I need SUM the values of this columns, but, I get the error "The SUM function only accepts a column reference as argument".

 

I have been reading documentation, and apparently, it is not possible because the SUM function only allows the use of a table column, and when I create a table, and assign it to a measure, it is not treated strictly as a table and therefore, there is no column to execute the sum.


P.S.: the variable will not be used to create a table, but to calculate it with other variables in the creation of a column.

 

Any idea how to solve it?

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

hi @andersonm 

you are right. SUM cannot do that but SUMX can. You can even skip the SELECTCOLUMNS part and use

SUMX ( HORASINTERM, [HorasInterm] )

 

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

hi @andersonm 

you are right. SUM cannot do that but SUMX can. You can even skip the SELECTCOLUMNS part and use

SUMX ( HORASINTERM, [HorasInterm] )

 

Thank you @tamerj1 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors