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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
MBZA
Helper I
Helper I

Replacing SUMMARIZECOLUMNS with SUMMARIZE to get measure that works in Desktop to work in Fabric

I'm having an issue with a measure that works fine in Desktop but fails after publishing, I think because of the context filter issues with SUMMARIZECOLUMNS.

 

I'm using a dataset called "Combined Data" that looks like the following:

FiscalYearFiscal QuarterClientDealQuote YearQuote Effective DateQuote Termination DateQuarter Start DateQuarter End DateActual RevenueQuote Estimated RevenueRow IndexQuote Last RowNegligible
20212021-Q1AA2010  2021/01/012021/03/31  75FalseFalse
20212021-Q1AB2011  2021/01/012021/03/31  76FalseFalse
20212021-Q1AC20152015/12/312016/12/302021/01/012021/03/31 150297.544FalseFalse
20212021-Q1AD20132013/12/312014/12/302021/01/012021/03/31 267745.9852FalseFalse
20212021-Q1AE20122012/12/312013/12/302021/01/012021/03/31 267745.9860FalseFalse
20212021-Q2AB2011  2021/04/012021/06/307.93 73FalseFalse
20212021-Q2AA2010  2021/04/012021/06/3017.48 74FalseFalse
20212021-Q2AC20152015/12/312016/12/302021/04/012021/06/3017.53150297.543FalseFalse
20212021-Q2AD20132013/12/312014/12/302021/04/012021/06/30688.39267745.9851FalseFalse
20212021-Q2AE20122012/12/312013/12/302021/04/012021/06/3026.51267745.9859FalseFalse
20212021-Q3AA2010  2021/07/012021/09/3017.14 71FalseFalse
20212021-Q3AB2011  2021/07/012021/09/307.77 72FalseFalse
20212021-Q3AC20152015/12/312016/12/302021/07/012021/09/3017.19150297.542FalseFalse
20212021-Q3AD20132013/12/312014/12/302021/07/012021/09/30675.21267745.9850FalseFalse
20212021-Q3AE20122012/12/312013/12/302021/07/012021/09/3026.03267745.9858FalseFalse
20212021-Q4AB2011  2021/10/012021/12/317.54 69FalseFalse
20212021-Q4AA2010  2021/10/012021/12/3116.6 70FalseFalse
20212021-Q4AC20152015/12/312016/12/302021/10/012021/12/3116.63150297.541TrueFalse
20212021-Q4AD20132013/12/312014/12/302021/10/012021/12/31654267745.9849TrueFalse
20212021-Q4AE20122012/12/312013/12/302021/10/012021/12/3125.2267745.9857TrueFalse
20222022-Q1AB2011  2022/01/012022/03/316.6 67FalseFalse
20222022-Q1AA2010  2022/01/012022/03/3114.53 68FalseFalse
20222022-Q1AC20152015/12/312016/12/302022/01/012022/03/3114.56150297.540FalseFalse
20222022-Q1AD20132013/12/312014/12/302022/01/012022/03/31571.99267745.9848FalseFalse
20222022-Q1AE20122012/12/312013/12/302022/01/012022/03/3122.05267745.9856FalseFalse
20222022-Q2AB2011  2022/04/012022/06/305.77 65FalseFalse
20222022-Q2AC20152015/12/312016/12/302022/04/012022/06/3012.78150297.539FalseFalse
20222022-Q2AA2010  2022/04/012022/06/30-1.4988E-15 66FalseTrue
20222022-Q2AE20122012/12/312013/12/302022/04/012022/06/30-1.71267745.9855FalseFalse
20222022-Q2AD20132013/12/312014/12/302022/04/012022/06/30-44.35267745.9847FalseFalse
20222022-Q3AB2011  2022/07/012022/09/305.46 63FalseFalse
20222022-Q3AC20152015/12/312016/12/302022/07/012022/09/3012.08150297.538FalseFalse
20222022-Q3AA2010  2022/07/012022/09/30-4.85723E-17 64FalseTrue
20222022-Q3AE20122012/12/312013/12/302022/07/012022/09/30-1.78267745.9854FalseFalse
20222022-Q3AD20132013/12/312014/12/302022/07/012022/09/30-46.16267745.9846FalseFalse
20222022-Q4AB2011  2022/10/012022/12/315.54 61FalseFalse
20222022-Q4AC20152015/12/312016/12/302022/10/012022/12/3112.26150297.537TrueFalse
20222022-Q4AA2010  2022/10/012022/12/311.51268E-15 62FalseTrue
20222022-Q4AE20122012/12/312013/12/302022/10/012022/12/31-1.87267745.9853TrueFalse
20222022-Q4AD20132013/12/312014/12/302022/10/012022/12/31-48.75267745.9845TrueFalse
20212021-Q1BF2011  2021/01/012021/03/31  36FalseFalse
20212021-Q2BF2011  2021/04/012021/06/300.33 35FalseFalse
20212021-Q3BF2011  2021/07/012021/09/304.68 34FalseFalse
20212021-Q4BF2011  2021/10/012021/12/314.54 33FalseFalse
20222022-Q1BF2011  2022/01/012022/03/313.98 32FalseFalse
20222022-Q2BF2011  2022/04/012022/06/303.77 31FalseFalse
20222022-Q3BF2011  2022/07/012022/09/303.29 30FalseFalse
20222022-Q4BF2011  2022/10/012022/12/313.34 29FalseFalse
20222022-Q1CG20222022/01/012022/12/312022/01/012022/03/311195263.637961078.947FalseFalse
20222022-Q1CH20212021/01/012021/12/312022/01/012022/03/311739761.69522905.2414FalseFalse
20222022-Q1CI20202020/01/012020/12/312022/01/012022/03/31 9181739.6921FalseFalse
20222022-Q1CJ20142014/06/152014/12/302022/01/012022/03/31 2270329.628FalseFalse
20222022-Q2CG20222022/01/012022/12/312022/04/012022/06/30-1102847.987961078.945FalseFalse
20222022-Q2CH20212021/01/012021/12/312022/04/012022/06/30-1632043.929522905.2413FalseFalse
20222022-Q2CI20202020/01/012020/12/312022/04/012022/06/30247.349181739.6919FalseFalse
20222022-Q2CJ20142014/06/152014/12/302022/04/012022/06/30117.872270329.627FalseFalse
20222022-Q3CG20222022/01/012022/12/312022/07/012022/09/308.52651E-147961078.943FalseTrue
20222022-Q3CH20212021/01/012021/12/312022/07/012022/09/307.28306E-149522905.2410FalseTrue
20222022-Q3CJ20142014/06/152014/12/302022/07/012022/09/30-1.33227E-142270329.625FalseTrue
20222022-Q3CI20202020/01/012020/12/312022/07/012022/09/308.21565E-159181739.6918FalseTrue
20222022-Q4CG20222022/01/012022/12/312022/10/012022/12/312.38032E-137961078.941TrueTrue
20222022-Q4CH20212021/01/012021/12/312022/10/012022/12/31-1.47438E-139522905.249FalseTrue
20222022-Q4CJ20142014/06/152014/12/302022/10/012022/12/317.88258E-152270329.623FalseTrue
20222022-Q4CI20202020/01/012020/12/312022/10/012022/12/31-1.04361E-149181739.6915TrueTrue

 

It is the result of merging two sets of data with different sorts of time granularities - a financial dataset with actual revenue by fiscal quarter and quote year, and a quotes dataset which has the effective date and termination date of different deals, as well as the revenue that was projected as at quote time. Basically I'm getting the most recent quote applicable at each fiscal period, and using the quote year to keep older quotes that are still applicable. The row index is calculated in the query based on a sort by Company, Deal, Quote Effective Date and Fiscal Quarter, in order to identify the most recent row that I want to use, and quote last row is a calculated column such that it identifies whether the row is the last for a given quote and a given fiscal year.

 

I also have a calendar table "Calendar" covering the period, with a join from "Date" to "Quarter Start Date", and a disconnected table with a single column called "Include" which is either True/False that I'm using as a switch (see below).

 

I'm trying to produce visuals that show the most recent quote revenue to contrast actuals. If I have date as an axis it needs to show the most recent revenue as at that date (in practice I'm not drilling down further than year), but it needs to roll up correctly into subtotals and grand totals (by date) for any other dimensions (company, deal, and many other columns in the real dataset). The measure I'm using in Desktop is as follows, and it works as I want it to:

 

Latest Quote Revenue USD =
VAR includeclosed = SELECTEDVALUE('Closed Business'[Include], TRUE) // This is the disconnected table/slicer switch - not too important

VAR filtered = FILTER('Combined Data', 'Combined Data'[Quarter Start Date] < 'Combined Data'[Quote Termination Date] || ('Combined Data'[Negligible] = FALSE && includeclosed = TRUE))

VAR summ = SUMMARIZECOLUMNS('Combined Data'[Company], 'Calendar'[Year], filtered, "val",

        CALCULATE(MAX('Combined Data'[Quote Estimated Revenue]), FILTER(filtered, 'Combined Data'[Row Index]=MAX('Combined Data'[Row Index]))))

    RETURN SUMX(summ, [val])

 

Unfortunately this doesn't work in Fabric for me, and I understand this is because of limitations with SUMMARIZECOLUMNS there. (Calculation error in measure 'Combined Data'[Latest Quote Revenue USD]: SummarizeColumns() and AddMissingItems() may not be used in this context.)

 

What is the correct way to translate this to not use SUMMARIZECOLUMNS? Is there a better approach I could be using overall?

 

1 ACCEPTED SOLUTION
MBZA
Helper I
Helper I

I managed to resolve this with the following code:

I added a new column

Quote Last Row excl Negl. =
VAR lastindex = CALCULATE(MAXX('Combined Data', 'Combined Data'[Row Index]-IF('Combined Data'[Negligible],100,0)), ALLEXCEPT('Combined Data', 'Combined Data'[Quote ID], 'Combined Data'[Report Type], 'Combined Data'[FiscalYear]))
RETURN 'Combined Data'[Row Index] = lastindex

then

Latest Quote Revenue USD test2 =
VAR includeclosed = SELECTEDVALUE('Closed Business'[Include], TRUE)
VAR summ = ADDCOLUMNS(SUMMARIZE('Combined Data', 'Combined Data'[Company], 'Calendar'[Year], 'Combined Data'[Quote Year]),"val",
        CALCULATE(MAX('Combined Data'[Quote Estimated Revenue]), 'Combined Data'[Quote Last Row excl Negl.]  && ('Combined Data'[Quarter Start Date] < 'Combined Data'[Quote Termination Date] || ('Combined Data'[Negligible] = FALSE && includeclosed = TRUE))))
    RETURN SUMX(summ, [val])

View solution in original post

4 REPLIES 4
MBZA
Helper I
Helper I

I managed to resolve this with the following code:

I added a new column

Quote Last Row excl Negl. =
VAR lastindex = CALCULATE(MAXX('Combined Data', 'Combined Data'[Row Index]-IF('Combined Data'[Negligible],100,0)), ALLEXCEPT('Combined Data', 'Combined Data'[Quote ID], 'Combined Data'[Report Type], 'Combined Data'[FiscalYear]))
RETURN 'Combined Data'[Row Index] = lastindex

then

Latest Quote Revenue USD test2 =
VAR includeclosed = SELECTEDVALUE('Closed Business'[Include], TRUE)
VAR summ = ADDCOLUMNS(SUMMARIZE('Combined Data', 'Combined Data'[Company], 'Calendar'[Year], 'Combined Data'[Quote Year]),"val",
        CALCULATE(MAX('Combined Data'[Quote Estimated Revenue]), 'Combined Data'[Quote Last Row excl Negl.]  && ('Combined Data'[Quarter Start Date] < 'Combined Data'[Quote Termination Date] || ('Combined Data'[Negligible] = FALSE && includeclosed = TRUE))))
    RETURN SUMX(summ, [val])
lbendlin
Super User
Super User

The issue is not with SUMMARIZECOLUMNS. The issue is that you are adding calculations directly, messing with the context.  The recommendation is to use ADDCOLUMNS on top of SUMMARIZECOLUMNS.

 

Also, this: https://xxlbi.com/blog/power-bi-antipatterns-9/

Thanks for the response, but please can you elaborate? I've seen the pattern of using ADDCOLUMNS with SUMMARIZE (which I can't get to do what I want) but I haven't seen it with SUMMARIZECOLUMNS. In fact all I can see is posts telling people to switch to using SUMMARIZECOLUMNS by itself.

 

Getting rid of the table filter as below is also changing my results:

Latest Quote Revenue USD test = 
VAR includeclosed = SELECTEDVALUE('Closed Business'[Include], TRUE)
VAR summ = SUMMARIZECOLUMNS('Combined Data'[Company], 'Calendar'[Year], 'Combined Data', "val",
CALCULATE(MAX('Combined Data'[Quote Estimated Revenue]), ('Combined Data'[Row Index]=MAX('Combined Data'[Row Index])) && ('Combined Data'[Quarter Start Date] < 'Combined Data'[Quote Termination Date] || ('Combined Data'[Negligible] = FALSE && includeclosed = TRUE))))
RETURN SUMX(summ, [val])

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.