March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I have the following measure, which works on a total level, but not in a table visual with fields from another table (dimCampaigns):
Unique Opened =
CALCULATE (
COUNTROWS (
SUMMARIZECOLUMNS(
fctActivities[CONTACT_ID],
fctActivities[CAMPAIGNID],
fctActivities[SUBJECTLINE],
"CountEmailOpen",
CALCULATE (
COUNTROWS ( fctActivities ),
fctActivities[ACTIVITYTYPE] = "EmailOpen"
)
)
)
)
This is probably because SUMMARIZECOLUMNS doesn't have a row context (as stated by this article). So I figured I would have to somehow retrieve such a value from the filter context of the table visual containing data from 'dimCampaigns' into the measure manually (by using VALUES). So I created the following:
Unique Opened =
CALCULATE (
COUNTROWS (
SUMMARIZECOLUMNS(
fctActivities[CONTACT_ID],
fctActivities[CAMPAIGNID],
fctActivities[SUBJECTLINE],
"CountEmailOpen",
CALCULATE (
COUNTROWS ( fctActivities ),
fctActivities[ACTIVITYTYPE] = "EmailOpen",
VALUES(dimCampaigns[CAMPAIGNCATEGORY]),
VALUES(dimCampaigns[NAME])
)
)
)
)
This still works on the total level, but still not in the table visual. It's the following table visual where I would like to add the measure to, but if I use the above measure it gives the dreaded error "SummarizeColumns() and AddMissingItems() may not be used in this context.":
I think I'm close, but I just cannot get it to work. Any help would be much appreciated, thank you!
I don't think you'll get SUMMARIZECOLUMNS working in a measure, try using ADDCOLUMNS .. SUMMARIZE instead, e.g.
Unique Opened =
CALCULATE (
COUNTROWS (
ADDCOLUMNS (
SUMMARIZE (
fctActivities,
fctActivities[CONTACT_ID],
fctActivities[CAMPAIGNID],
fctActivities[SUBJECTLINE]
),
"CountEmailOpen",
CALCULATE (
COUNTROWS ( fctActivities ),
fctActivities[ACTIVITYTYPE] = "EmailOpen"
)
)
)
)
Hi @johnt75 ,
Thanks for your reply! It's not an ideal solution, but what I did now is the following:
Subset =
SUMMARIZECOLUMNS(
fctActivities[CONTACT_ID],
fctActivities[CAMPAIGNID],
"CountEmailOpen",
CALCULATE (
COUNTROWS ( fctActivities ),
fctActivities[ACTIVITYTYPE] = "EmailOpen"
)
)
Unique Opened = COUNTROWS('Subset')
Somehow it doesn't work to simply replace 'Subset' in the measure with the DAX code that's creating the calculated table, also not using variables, this probably has something to do with context transition not working.
Replacing the table name with the DAX, or a variable calculated from the DAX, won't work if you use SUMMARIZECOLUMNS, you can't use that in a measure. If you edit it to use ADDCOLUMNS ... SUMMARIZE then it might work
So you mean creating one single measure as the following? Because that doesn't work either...
Unique Opened =
CALCULATE (
COUNTROWS (
ADDCOLUMNS (
SUMMARIZE (
fctActivities,
fctActivities[CONTACT_ID],
fctActivities[CAMPAIGNID]
),
"CountEmailOpen",
CALCULATE (
COUNTROWS ( fctActivities ),
fctActivities[ACTIVITYTYPE] = "EmailOpen"
)
)
)
)
Try creating a temporary table to see if you can spot what the problem might be,
Tmp Table =
ADDCOLUMNS (
SUMMARIZE (
fctActivities,
fctActivities[CONTACT_ID],
fctActivities[CAMPAIGNID]
),
"CountEmailOpen",
CALCULATE (
COUNTROWS ( fctActivities ),
fctActivities[ACTIVITYTYPE] = "EmailOpen"
)
)
There is no problem with that code as such. The problem lies in the combination of that piece of code in a measure like below, the problem being that the measure is not properly filtered by (fields from) dimCampaigns in said table visual.
Unique Opened =
CALCULATE (
COUNTROWS (
ADDCOLUMNS (
SUMMARIZE (
fctActivities,
fctActivities[CONTACT_ID],
fctActivities[CAMPAIGNID]
),
"CountEmailOpen",
CALCULATE (
COUNTROWS ( fctActivities ),
fctActivities[ACTIVITYTYPE] = "EmailOpen"
)
)
),FILTER('Subset', 'Subset'[CountEmailOpen] > 0)
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
17 | |
17 | |
7 | |
5 |
User | Count |
---|---|
31 | |
27 | |
20 | |
13 | |
12 |