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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Calculate UID wise

Hi Team,

 

I need your help, regarding below column formulas,

1) Remaing UID Stock - > When the UID's are same then Prod_Total should be summed up and at the same time, the difference between the "Prod_Total" and "stock" of each "category" should be found.
And this should work based on dynamic slicer. eg: if slicer is Oct month then Prod_Total should be calculated from Jan to Oct .
  

Note: Prod_Total is Measures (calculates new measure)


screen.PNG

Thanks,

KV's

9 REPLIES 9
AllisonKennedy
Super User
Super User

Sorry, you have covered up UID - which rows are they the same for? How many tables is your raw data? This could be done with the right table visual or ifyou create a measure:

 

UID Prod Total = CALCULATE(SUM{Table[Prod_Total]), ALL{Table[Category]))

 

Then subtract that from stock in another or same measure. I'm just not sure how many tables you have and how they are related, so that may change things slightly.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

@Anonymous 

 

You should be able to do as a new measure:

 

Remaining UID Stock = MAX(Table[Stock]) - CALCULATE(SUM(Table[Prod_Total]), ALL(Table[Category]))

 

or as a new COLUMN:

 

Remaining UID Stock = Table[Stock] - SUMX(FILTER(ALL(Table), Table[UID] = EARLIER(Table[UID])), Table[Prod_Total])


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

screen_II.PNG

@Anonymous , try like

 

remaining UID Stock = sum(Table[stock])- calculate(sum(Table[Prod_Total]) , allexcept(Table, Table[UID]))
or
remaining UID Stock = calculate(sum(Table[Prod_Total]) , allexcept(Table, Table[UID])) -sum(Table[stock])

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 , how it will work with dynamic slicer (Date table, UID table separate).

amitchandak
Super User
Super User

@Anonymous , not very clear. to me it seem like

remaining UID Stock = sum(Table[Prod_Total]) -sum(Table[stock])

 

remaining UID Stock PO = if([remaining UID Stock]<0, 0, [remaining UID Stock])

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 ,

 

I'm expected below result,

screen_II.PNG

Anonymous
Not applicable

Hi @amitchandak ,

expected based on UID (same ID) prod_total subtract by each Category row wise..

 

Thanks,

KV's 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors