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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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