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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
victorlopes1998
New Member

Sumx() returning wrong total

Hello all!

 

I'm trying to monthly my weight by distinct count of dates doing:

 

MONTHLY WEIGHT = SUMX(Plan1,
DIVIDE(Plan1[WEIGHT],DISTINCTCOUNT(Plan1[DATE])))
 
victorlopes1998_1-1666189335911.png
 
And I need to get the sum of results line by line to show as a card
 
But I'm getting the wrong result:
 
aa.PNG
The correct result is 173+113 = 286 instead of 221.
 
victorlopes1998_0-1666189305266.png

 

 
 

 

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@victorlopes1998,

 

Try this measure:

 

MONTHLY WEIGHT = 
VAR vTable =
    ADDCOLUMNS (
        SUMMARIZE ( Plan1, Plan1[DESTINY], Plan1[ORIGIN] ),
        "@Weight", CALCULATE ( SUM ( Plan1[WEIGHT] ) ),
        "@CountDistinctDate", CALCULATE ( DISTINCTCOUNT ( Plan1[DATE] ) )
    )
VAR vResult =
    SUMX ( vTable, DIVIDE ( [@Weight], [@CountDistinctDate] ) )
RETURN
    vResult

 

DataInsights_0-1666205508699.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@victorlopes1998,

 

Try this measure:

 

MONTHLY WEIGHT = 
VAR vTable =
    ADDCOLUMNS (
        SUMMARIZE ( Plan1, Plan1[DESTINY], Plan1[ORIGIN] ),
        "@Weight", CALCULATE ( SUM ( Plan1[WEIGHT] ) ),
        "@CountDistinctDate", CALCULATE ( DISTINCTCOUNT ( Plan1[DATE] ) )
    )
VAR vResult =
    SUMX ( vTable, DIVIDE ( [@Weight], [@CountDistinctDate] ) )
RETURN
    vResult

 

DataInsights_0-1666205508699.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you!!! It works fine and solve my problem!!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors