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
sheenajose
Frequent Visitor

sum on distinct value based on month column

Hi,

I have a table with month,activity and value columns.

MonthActivityValueValueTotal
JanA921217282
JanA921217282
JanB574617282
JanB574617282
JanC175217282
JanC175217282
JanD57217282
JanD57217282
FebA2509659342
FebA2509659342
FebB2365059342
FebB2365059342
FebC710959342
FebC710959342
FebD348759342
FebD348759342
MarA2708368068
MarA2708368068
MarB2886068068
MarB2886068068
MarC685268068
MarC685268068
MarD527368068
MarD527368068

I would like to have calculated column to sum on distinct Value based on month coulumn,

the result expected is of ValueTotal column

i was able to take the distinct value and sum  but unable to add filter on month before sum

ValueTotal= SUMX(SUMMARIZE('Table1','Table1'[Value]),'Table1'[value])

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Hi, @sheenajose , you might want to try this formula in a calcaulated column,

 

TotalDistinctValue =
SUMX (
    CALCULATETABLE (
        DISTINCT ( 'Table1'[Value] ),
        ALLEXCEPT ( 'Table1', 'Table1'[Month] )
    ),
    'Table1'[Value]
)

 

 

or equally,

 

TotalDistinctValue 2 =
SUMX (
    CALCULATETABLE (
        DISTINCT ( Table1[Value] ),
        FILTER ( Table1, [Month] = EARLIER ( Table1[Month] ) )
    ),
    Table1[Value]
)

 

 

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

Hi, @sheenajose , you might want to try this formula in a calcaulated column,

 

TotalDistinctValue =
SUMX (
    CALCULATETABLE (
        DISTINCT ( 'Table1'[Value] ),
        ALLEXCEPT ( 'Table1', 'Table1'[Month] )
    ),
    'Table1'[Value]
)

 

 

or equally,

 

TotalDistinctValue 2 =
SUMX (
    CALCULATETABLE (
        DISTINCT ( Table1[Value] ),
        FILTER ( Table1, [Month] = EARLIER ( Table1[Month] ) )
    ),
    Table1[Value]
)

 

 

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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.