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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
fatimaarshd
Helper I
Helper I

How to calculate sum of column

This is what my data looks like:

fatimaarshd_0-1698174019839.png

Please note this is just for category A. I have other categories as well. But all of them have channels and date and total orders etc. I want to calculate weekly sum for each category. However, I want to discount channel. I would like to show it in visual but the value of sum should be constant for all.

In the above case. 524+532+499+412+617 = 2584

I have this DAX:

Weekly Notification Sum =
VAR _max = MAXX(all(Consolidated), Consolidated[ Channel])
VAR _min = MAXX(ALL(Consolidated), Consolidated[Channel])
RETURN
CALCULATE(
SUM(Consolidated[Nudges]),
FILTER(Consolidated, Consolidated[ Channel] = _min || Consolidated[ Channel] = _max )
)

 

This one ofcourse doenst give me correct value. It takes max of each channel and then gives me that. 

Tried many things but I am extremely clueless.

 

Edit:

This solution works fine until I add another  column Channel into context. 

Weekly Notification Sum =
VAR _Distinct_ =
SUMMARIZE (
Consolidated,
Consolidated[Type],
Consolidated[Date],
Consolidated[Total notifications]
)
RETURN
SUMX ( _Distinct_, Consolidated[Total notifications] )

 

4 REPLIES 4
AlexisOlson
Super User
Super User

To avoid counting the value multiple times, you can group the relevant columns before summing.

 

For example:

Weekly Notification Sum =
VAR _Distinct_ =
    SUMMARIZE (
        Consolidated,
        Consolidated[Type],
        Consolidated[Date],
        Consolidated[Total notifications]
    )
RETURN
    SUMX ( _Distinct_, Consolidated[Total notifications] )

How do I make it not get affected by channel in the visual? When I add Channel it shows a different sum for each channel. I want it to show 2584 for all channels. 

fatimaarshd_0-1698176077624.png

 

 

@AlexisOlson  What would you suggest the correct approach would be?

 

One approach would be to remove all filter context except the columns you're summarizing.

 

Try this, for example:

Weekly Notification Sum =
VAR _Distinct_ =
    CALCULATETABLE (
        SUMMARIZE (
            Consolidated,
            Consolidated[Type],
            Consolidated[Date],
            Consolidated[Total notifications]
        ),
        ALLEXCEPT (
            Consolidated,
            Consolidated[Type],
            Consolidated[Date],
            Consolidated[Total notifications]
        )
    )
RETURN
    SUMX ( _Distinct_, Consolidated[Total notifications] )

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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