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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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
v-yangliu-msft
Community Support
Community Support

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
v-yangliu-msft
Community Support
Community Support

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.