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
Anonymous
Not applicable

Subtraction Row wise Calculation

Hi Team,

 

DAX - based on UID (Unique) total sum value subtraction with each UID Category like row wise, could you please help me.

 

Note:

1) stock and sal_total both are measures value (calculated new measures)

2) Blac_Manual -> expected result (Manual Calculation 

3) Cat -> row wise subtract UID sum of total like first ex : GH-258 Stock is 14 - 5 (UID sum) = expecting result is 9

 

formul Not working : 

balc = sumx(filter(Sheet2, [UID] = earlier([UID]) ),[Stock]) - maxx(filter(Sheet2, [UID] = earlier([UID]) ),[Production])

 

 

screen.PNG

 

Thanks,

KV's

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous  ,

According to your description, I create this data:

v-yangliu-msft_0-1608623989090.png

Here are the steps you can follow:

1. Create measure.

Stock: Cat category value when uid is consistent

stock =
CALCULATE(SUM('Table'[amount]),FILTER('Table','Table'[Cat]=MAX('Table'[Cat])))
sal_total:Sum by [cat] class UID

sal_total =
var _UID=CALCULATE(MAX('Table'[UID]),FILTER(ALL('Table'),[Cat]=MAX('Table'[Cat])))
return
CALCULATE(COUNT('Table'[UID]),FILTER(ALL('Table'),'Table'[UID]=_UID))
Blac_Manual:Expected results

Balc_Manual = [stock]-[sal_total]

2. Result

v-yangliu-msft_1-1608623989093.png

You can downloaded PBIX file from here.

 

If my answer is not what you need, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @Anonymous  ,

According to your description, I create this data:

v-yangliu-msft_0-1608623989090.png

Here are the steps you can follow:

1. Create measure.

Stock: Cat category value when uid is consistent

stock =
CALCULATE(SUM('Table'[amount]),FILTER('Table','Table'[Cat]=MAX('Table'[Cat])))
sal_total:Sum by [cat] class UID

sal_total =
var _UID=CALCULATE(MAX('Table'[UID]),FILTER(ALL('Table'),[Cat]=MAX('Table'[Cat])))
return
CALCULATE(COUNT('Table'[UID]),FILTER(ALL('Table'),'Table'[UID]=_UID))
Blac_Manual:Expected results

Balc_Manual = [stock]-[sal_total]

2. Result

v-yangliu-msft_1-1608623989093.png

You can downloaded PBIX file from here.

 

If my answer is not what you need, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Anonymous , Logic is not very clear.

 

Create a new measure like

balc = sumx(filter(allselected(Sheet2), [UID] = max([UID]) ),[Stock]) - maxx(filter(allselected(Sheet2), [UID] = max([UID]) ),[Production])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,

 

It's working DIM based total sum, but I'm expecting DIM while including Category then total volume split like below,

screen.PNG

 

 

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