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
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
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.