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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Coriel-11
Resolver II
Resolver II

"SummarizeColumns() and AddMissingltems() may not be used in this context" [a Measure in a matrix]

Hi Everyone,

I'm trying to create a measure that finds the highest monthly total of clicks from a range of months, but been having problems. I've managed to do this by creating a new (calculated) table using SUMMARIZECOLUMNS and applying a measure, but that seems inefficient. Really I just want to do all that in a measure.

So I've created a new measure, used a couple of variables to create the table and then am using the same basic bit of code in the return section as worked before, only now I get this error message (when I click on details):

Couldn't load the data for this visual
MdxScript(Model) (193, 13) Calculation error in measure 'Measures
Table'[Hotspot]: SummarizeColumns() and AddMissingltems() may
not be used in this context.

Any ideas why?
Here's my measure code (the bit above the return works fine to produce a stand alone table)

 

 

 

Hotspot = 
var tablx = SUMMARIZECOLUMNS(Dates[MonthYr],Clicks[link name],"Total Clicks",SUM(Clicks[unique clicks]))
Return
CALCULATE(MAXX(tablx,[Total Clicks]))

 

 

 

 Thanks,

Matt

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can't use SUMMARIZECOLUMNS in a measure, you need to use a combination of ADDCOLUMNS and SUMMARIZE. Try

Hotspot =
VAR tablx =
    ADDCOLUMNS (
        SUMMARIZE ( Clicks, Dates[MonthYr], Clicks[link name] ),
        "Total Clicks", CALCULATE ( SUM ( Clicks[unique clicks] ) )
    )
RETURN
    CALCULATE ( MAXX ( tablx, [Total Clicks] ) )

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

You can't use SUMMARIZECOLUMNS in a measure, you need to use a combination of ADDCOLUMNS and SUMMARIZE. Try

Hotspot =
VAR tablx =
    ADDCOLUMNS (
        SUMMARIZE ( Clicks, Dates[MonthYr], Clicks[link name] ),
        "Total Clicks", CALCULATE ( SUM ( Clicks[unique clicks] ) )
    )
RETURN
    CALCULATE ( MAXX ( tablx, [Total Clicks] ) )

Thanks @johnt75 . I hadn't realised that about SUMMARIZECOLUMNS.

The only thing is that when I put it into a matrix with the "Dates[MonthYr]" field as a column, it still just gives me the max (i.e. same as the sum) for each month, even once, I've added an ALL(Dates[MonthYr]) into the second CALCULATE function.

Any idea why that bit's not working?

 

Matt

The summary table is still being filtered by the date, try

Hotspot =
VAR tablx =
    ADDCOLUMNS (
        CALCULATETABLE (
            SUMMARIZE ( Clicks, Dates[MonthYr], Clicks[link name] ),
            REMOVEFILTERS ( Dates )
        ),
        "Total Clicks", CALCULATE ( SUM ( Clicks[unique clicks] ) )
    )
RETURN
    CALCULATE ( MAXX ( tablx, [Total Clicks] ) )

Thanks for this, I just had to tweak it to move the removefilters to outside of the ADDCOLUMNS, rather than just inside and then it worked.

Hotspot = 
var tablx = 
CALCULATETABLE(
    ADDCOLUMNS (     
        SUMMARIZE ( Clicks, Dates[MonthYr], Clicks[link name] ),
        "Total Clicks", CALCULATE ( SUM ( Clicks[unique clicks] ) ) ),
    REMOVEFILTERS(Dates)
) 
RETURN 
    CALCULATE ( MAXX ( tablx, [Total Clicks] ))

Thank you so much. Much appreciated.

Matt

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.