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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors