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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

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 @Anonymous 

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 @Anonymous 

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

SUMX ( HORASINTERM, [HorasInterm] )

 

Anonymous
Not applicable

Thank you @tamerj1 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.