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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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])

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

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.