Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
How to calculate difference between count of Active & Negative Ppl for each segment in DAX
e.g.
in below table Blank segment has 3 active & 6 negative so the diff is -3
so the final table should look this
Segment | difference
Blank | -3
etc
| PeopleType | Segment |
| Active | BLANK |
| Active | BLANK |
| Active | BLANK |
| Negative | BLANK |
| Negative | BLANK |
| Negative | BLANK |
| Negative | BLANK |
| Negative | BLANK |
| Negative | BLANK |
| Passive | BLANK |
| Passive | BLANK |
| Active | EC |
| Active | EC |
| Passive | EC |
| Active | Resident |
| Active | Resident |
| Active | Resident |
| Negative | Resident |
| Negative | Resident |
| Passive | Resident |
| Active | SME |
| Active | SME |
| Negative | SME |
| Negative | SME |
| Passive | SME |
Solved! Go to Solution.
Hi @socksinbox ,
It can be segment wise, you just create a table and drag the segment column into it,
then create the measue I did, then drag to it, you will see the result.
Or do you mean you want to use a DAX to create a new table with segment column and diff column?
Aiolos Zhao
Hi @socksinbox ,
If you want to create a new table, please use below expression :
Table = SUMMARIZE(Table4,Table4[Segment],"Diff",CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Active") - CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Negative"))
Thanks.
Aiolos Zhao
Hi,
Based on the data that you have shared, the average should be 0. Try this measure
Measure = AVERAGEX(SUMMARIZE(CALCULATETABLE(Data,Data[PeopleType]="Active"||Data[PeopleType]="Negative"),Data[Segment],"Active",CALCULATE(COUNTROWS(Data),Data[PeopleType]="Active"),"Negative",CALCULATE(COUNTROWS(Data),Data[PeopleType]="Negative")),[Active]-[Negative])
Hi @socksinbox ,
Please try to use below measure, it works in my demo :
CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Active") - CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Negative")
Thanks.
Aiolos Zhao
Thanks @Anonymous for this.
Actually this will calculate the overall difference, however, I would like to have segment wise difference. So I would need to return a table not a measure
thanks
Hi @socksinbox ,
It can be segment wise, you just create a table and drag the segment column into it,
then create the measue I did, then drag to it, you will see the result.
Or do you mean you want to use a DAX to create a new table with segment column and diff column?
Aiolos Zhao
Yes.. I mean I would like to create a new data table.
Actually, once I will have the segment-wise difference then I will create a measure on the top of that which will take the average of all differences and show in a card visual
cheers
Hi,
Based on the data that you have shared, the average should be 0. Try this measure
Measure = AVERAGEX(SUMMARIZE(CALCULATETABLE(Data,Data[PeopleType]="Active"||Data[PeopleType]="Negative"),Data[Segment],"Active",CALCULATE(COUNTROWS(Data),Data[PeopleType]="Active"),"Negative",CALCULATE(COUNTROWS(Data),Data[PeopleType]="Negative")),[Active]-[Negative])
You are welcome.
Hi @socksinbox ,
If you want to create a new table, please use below expression :
Table = SUMMARIZE(Table4,Table4[Segment],"Diff",CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Active") - CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Negative"))
Thanks.
Aiolos Zhao
Thanks @Anonymous for your help
Glad to help you ~
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 30 | |
| 23 | |
| 23 | |
| 23 | |
| 14 |
| User | Count |
|---|---|
| 48 | |
| 33 | |
| 20 | |
| 18 | |
| 16 |