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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rohannimje
New Member

How do I Calculate reduced qty

rohannimje_0-1661944621928.png

How to calculate the pending qty. 
My measure to calculate pending qty = [TotalOrderedQty] - [TotalBilledQty]
But the results are not satisfactory. 

ORDER NOMATERIAL CODETotalOrderdQtyBILLED QUANTITYMonthInCalendarPendingQty APendingQty BDate
4.51E+0990003847 3750Jun-22-3750010-06-2022 00:00
4.51E+0990003847 4350May-22-4350375020-05-2022 00:00
4.51E+09900038478100 Nov-218100 03-11-2021 00:00

 

Above table shows the 2 pendingQty column

PendingQty A - is the results I get

PendingQty B - is the results which I expected.

 

 

So anyone please help me that how should I get the result as shown in "pendnigQty B" column.

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @rohannimje 

 

You can try the following methods.

PreTotal = 
Var PrevDate=MAXX(FILTER(ALL('Table'[Date]),'Table'[Date]<SELECTEDVALUE('Table'[Date])),[Date])
Var PreTotal=CALCULATE([TotalOrderdQty],FILTER(ALL('Table'),[Date]=PrevDate))
Return
PreTotal
PendingQty B = IF([PreTotal]=BLANK(),BLANK(),[PreTotal]-[TotalBilledQty])

vzhangti_0-1662362612559.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @rohannimje 

 

You can try the following methods.

PreTotal = 
Var PrevDate=MAXX(FILTER(ALL('Table'[Date]),'Table'[Date]<SELECTEDVALUE('Table'[Date])),[Date])
Var PreTotal=CALCULATE([TotalOrderdQty],FILTER(ALL('Table'),[Date]=PrevDate))
Return
PreTotal
PendingQty B = IF([PreTotal]=BLANK(),BLANK(),[PreTotal]-[TotalBilledQty])

vzhangti_0-1662362612559.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

Greg_Deckler
Super User
Super User

@rohannimje You will need something like:

Pending B Column =
  VAR __OrderNo = [ORDER NO]
  VAR __Material = [MATERIAL CODE]
  VAR __BilledQty = [BILLED QUANTITY]
  VAR __Date = [Date]
  VAR __Table = FILTER(ALL('Table'),[ORDER NO] = __OrderNo && [MATERIAL CODE] = __Material)
  VAR __TotalOrderedQty = SUMX(__Table, [TotalOrderedQty]
  VAR __Table2 = FILTER(__Table,[Date] <= __Date)
  VAR __BilledQty = SUMX(__Table2, [BILLED QUANTITY])
RETURN
  __TotalOrderedQty - __BilledQty

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.