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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
VendettaBob
Helper II
Helper II

SummarizeColumns() and AddMissingItems()

Hi,

 

I have the following code:

 

 

_CumulativeFrequencyRateThisYear = 
 var _table = SUMMARIZECOLUMNS(
      'EventYearMonth'[CalendarMonthId],
	  FILTER(
	      KEEPFILTERS(VALUES('EventYearMonth'[DateValue])),
	      AND(
	        'EventYearMonth'[DateValue] >= DATE(2022, 1, 1),
	        'EventYearMonth'[DateValue] < DATE(2023, 1, 1)
	      )),
      "_CumulativeFrequencyRateLocal", 'SHEQ'[_CumulativeFrequencyRate]
  )
RETURN
 AVERAGEX(_table,[_CumulativeFrequencyRateLocal])

 

 

I want to return a visual such as:

VendettaBob_0-1650628289328.png

 

However, when I place the measure in the visual with the  'EventYearMonth'[CalendarMonthId] as the axis I get the follwoing error:

 

SummarizeColumns() and AddMissingItems() may not be used in this context.

 

Any ideas?

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

The reason for this is that "SUMMARIZECOLUMNS cannot be used in a context transition. You could use it in a filter, but you cannot invoke SUMMARIZECOLUMNS in a measure because the measure is often called in a context transition." (From Marco's reply to a comment on this article.)

 

SUMMARIZECOLUMNS is great for writing DAX queries but if you're writing a measure, then you almost always need to use SUMMARIZE instead.

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

The reason for this is that "SUMMARIZECOLUMNS cannot be used in a context transition. You could use it in a filter, but you cannot invoke SUMMARIZECOLUMNS in a measure because the measure is often called in a context transition." (From Marco's reply to a comment on this article.)

 

SUMMARIZECOLUMNS is great for writing DAX queries but if you're writing a measure, then you almost always need to use SUMMARIZE instead.

amitchandak
Super User
Super User

@VendettaBob , try like

 


_CumulativeFrequencyRateThisYear =
var _table = ADDCOLUMNS(Summarize('SHEQ'
'EventYearMonth'[CalendarMonthId] ),
"_CumulativeFrequencyRateLocal", calculate('SHEQ'[_CumulativeFrequencyRate],FILTER(
KEEPFILTERS(VALUES('EventYearMonth'[DateValue])),
AND(
'EventYearMonth'[DateValue] >= DATE(2022, 1, 1),
'EventYearMonth'[DateValue] < DATE(2023, 1, 1)
)) ))
)
RETURN
AVERAGEX(_table,[_CumulativeFrequencyRateLocal])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors