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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Powerbi_superus
Frequent Visitor

Dax to get quantity based on max line item numbet

Please help for below dax formula

 

I have sales order number and itme number qith quantity


SONO ITEMNO Quantity

1000 1 10
1000 2 20
1000 3 60
1000 4 20
1001 3 50
1001 5 30


I should get sum quantity for each salesorder based on last itemno called new order quantity

I should get sum quantity for each salesorder based on all itemnumbers avoiding max itemno called order quantity


in above case i need quantity for sono 1000 with max itemno 4 and for sono 1000 sum up all quantities from itemno 1 to 3

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Powerbi_superus 

maybe you can try this

Measure 2 = CALCULATE(sum('Table (2)'[Quantity]),FILTER('Table (2)','Table (2)'[ITEMNO]=max('Table (2)'[ITEMNO])))

Measure 3 = 
VAR _MAX=MAX('Table (2)'[ITEMNO])
RETURN CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)','Table (2)'[ITEMNO]<_MAX))

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @Powerbi_superus 

Could you tell me if your problem has been solved? If it is, kindly Accept the helpful reply as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

ryan_mayu
Super User
Super User

@Powerbi_superus 

maybe you can try this

Measure 2 = CALCULATE(sum('Table (2)'[Quantity]),FILTER('Table (2)','Table (2)'[ITEMNO]=max('Table (2)'[ITEMNO])))

Measure 3 = 
VAR _MAX=MAX('Table (2)'[ITEMNO])
RETURN CALCULATE(SUM('Table (2)'[Quantity]),FILTER('Table (2)','Table (2)'[ITEMNO]<_MAX))

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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