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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jankriz
New Member

ADDCOLUMNS row context in CALCULATE condition

Hi,

 

I have a Table with picture pixels coordinates X and Y and number of clicks to each pixel from each user:

UserID    XYClicks

 

Each user could make any number of clicks to any pixel.

Now I want to make summarized table where will be one row for each pixel and SUM of clicks. But not only from that pixel but form it and surrounding pixels which are defined by number Brush.

My idea was something like this code:

 

 

 

var Brush = 10

return

ADDCOLUMNS(SUMMARIZE(Table,[X],[Y]),"SumClicks",CALCULATE(SUM(Table[Clicks]),ALL(Table[X],Table[Y]),AND(Table[X]<=[X]+Brush,Table[X]>=[X]-Brush)&&AND(Table[Y]<=[Y]+Brush,Table[Y]>=[Y]-Brush)))

 

 

 

 

But this doesn't work because [X] and [Y] form row context in summarized table can't be used in CALCULATE condition.

Have you any idea, how to make this work?

Thank you.

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @jankriz 

Try this to create a new calculated table:

NewTable = 
VAR Brush = 10
RETURN
    ADDCOLUMNS (
        SUMMARIZE ( Table1, Table1[X], Table1[Y] ),
        "SumClicks",
            CALCULATE (
                SUM ( Table1[Clicks] ),
                ALL ( Table1[X], Table1[Y] ),
                AND ( Table1[X] <= EARLIER(Table1[X]) + Brush, Table1[X] >= EARLIER(Table1[X]) - Brush )
                    && AND ( Table1[Y] <= EARLIER(Table1[Y]) + Brush, Table1[Y] >= EARLIER(Table1[Y]) - Brush )
            )
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

2 REPLIES 2
AlB
Community Champion
Community Champion

Hi @jankriz 

Try this to create a new calculated table:

NewTable = 
VAR Brush = 10
RETURN
    ADDCOLUMNS (
        SUMMARIZE ( Table1, Table1[X], Table1[Y] ),
        "SumClicks",
            CALCULATE (
                SUM ( Table1[Clicks] ),
                ALL ( Table1[X], Table1[Y] ),
                AND ( Table1[X] <= EARLIER(Table1[X]) + Brush, Table1[X] >= EARLIER(Table1[X]) - Brush )
                    && AND ( Table1[Y] <= EARLIER(Table1[Y]) + Brush, Table1[Y] >= EARLIER(Table1[Y]) - Brush )
            )
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

jankriz
New Member

Thank you @AlB , this works exactly how I need 😀

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric 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.

Users online (26)