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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Tinus1905
Resolver I
Resolver I

PowerBi sum of column grouped by other column

Hi,

 

I have a total of a measure and want to sum this by an other column. 

 

I have the following table. 

 

ID       Status           Type          Name   Value

123acceptyesyellow12
123acceptyes 10
456not possiblestandardgreen7
456not possiblestandard 3
789not possiblestandardgreen22
135acceptno 8

 

With the following formula I get the total of rows = 4

 

Count =
    CALCULATE(
    DISTINCTCOUNT(tableA[ID]),
    (tableA[Type] = "yes" || tableA[Type] = "no") ||
    (tableA[Status] = "not possible" &&
    tableA[Name] = "green"),
    REMOVEFILTERS(tableA[filter]))

 

 

ID       Status            Type         Name   Value

123acceptyesyellow12
456not possiblestandardgreen7
789not possiblestandardgreen22
135acceptno 8

 

Now I want to sum the Value column. Outcome must be: 49
What dax calculation should I use to get it in 1 formula. 
 
8 REPLIES 8
Tinus1905
Resolver I
Resolver I

@MFelix @shafiz_p ok, thanks. It seems that I have a little trouble with distinctcount. 

WhenI calculate and I apply filter 1, filter 2 etc, it is possible that I have duplicates. How can I use the filters and then remove the duplicates? 

Whath is the number you want to count and the total sum amount you want to have? 

 

Is it the one that you share has a result table:

 

MFelix_0-1720179891294.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Sorry I made a mistake. The value column isnt relevant anymore. 

All I have to do is use the measure and multiply by 34. 

So I want to use a new measure with first use the filters and then distinct.  

This is what I have (its working fine), but I need to distinct the ID column.
 
Count =
    CALCULATE(
    COUNTROWS([tableA[ID]),
    tableA[Type] = IN {"yes", "no"} ||
    tableA[Status] = "not possible" && tableA[Name] = "green",
    REMOVEFILTERS(tableA[filter]))
 
How can I distinct after the filters has been set. 
 
 
Anonymous
Not applicable

Hi @Tinus1905 

 

Actually I hcan not understand the explanation of the latest post completely.
IF possible, please provide more explanation of the details and please provide the your expected outcome.

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

shafiz_p
Super User
Super User

@Tinus1905According to your filter condition (tableA[Type] = "yes" || tableA[Type] = "no"), Both 123 id should come into play but distinct count eleminate one of them. Why it consider 12, why not it considering 10. 10 has equal chance as 12.

MFelix
Super User
Super User

Hi @Tinus1905 ,

 

For this you need to use SUMX something similar to this:

SUM =
    SUMX ( FILTER(tableA,
    (tableA[Type] = "yes" || tableA[Type] = "no") ||
    (tableA[Status] = "not possible" &&
    tableA[Name] = "green"),
), tableA[Value])

Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



The outcome = BLANK. And I dont see where the column ID is beeing grouped or distinctcount? 

Hi @Tinus1905 ,

 

In my mockup it's returning the value altough be aware that since your filter context includes yes and no the total is 51 because it has 10 and 12 for id 123

 

MFelix_0-1720104238568.png

In this case you do not need the distinct since you are calculating the values of the sum and not the ID per each one you are at a row level filter context.

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.