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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
One-Dash
Frequent Visitor

Dax for calculating how much item is left

Hello!  This might be a bit complicated, but i will try to explain as best i can.  i have two tables

Date - a table for calendaryear

Invoice - a table which includes list of  items with different columns to track their progress to completion. Column includes

              Ticket#, DateReceived, DateStarted, DateSentQA, DatePosted.

 

I want to track how many tickets are left at the end of each day.  I used to do this manually in excel by doing this calculation below

we have a known a starting point for the # of tickets on 1/1/2022 which is 700,  what makes this tricky is we have new tickets being added each day

Date

 start

New RequestsSent to QAPosted

End 

1/1/2022700311

702 

 

1/2/2022702654

704

 

1/3/2022704176

699

 

on the table 

start = #ticket at start of the day

New request column = #tickets with DateReceived same as Date value

Sent to Qa =  #tickets with DateSentQA same as Date value

Posted = #tickets with DatePosted same as Date value

End = Remaining ticket at end of the day  (Remaining Start+New Request - Posted)

 

 Using the end column from the table i make the chart below.  

OneDash_0-1678468456359.png

is there a way to do this in PBI where the End column values can be auto calculated with out having to use excel ?  thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  ,

Please have a try.

New request column =
CALCULATE (
    COUNT ( 'Table'[DATE RECEIVED] ),
    FILTER ( 'Table', 'Table'[DATE RECEIVED] = EARLIER ( 'date'[Date] ) )
)

Please cancel the relationship between the tables.

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

6 REPLIES 6
Anonymous
Not applicable

Hi @One-Dash ,

I have created a new sample, please refer to my pbix file to see if it helps you.

Measure =
VAR _a =
    SUMMARIZE (
        ALL ( 'Table' ),
        'Table'[date],
        "result", MAX ( 'Table'[new request] ) - MAX ( 'Table'[Posted] )
    )
RETURN
    700
        + SUMX ( FILTER ( _a, [date] <= MAX ( 'Table'[date] ) ), [result] )

 

vpollymsft_0-1678857987097.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

Invoice Table sample

DATE RECEIVEDDate StartedDate Sent to QADATE PostedTIME WORKED
31-Jan-23    
31-Jan-23    
30-Jan-23    
30-Jan-23    
30-Jan-23    
30-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
27-Jan-23    
26-Jan-23    
25-Jan-23    
25-Jan-23    
25-Jan-23    
25-Jan-23    
25-Jan-23    
25-Jan-23    
25-Jan-23    
25-Jan-23    
25-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
23-Jan-23    
19-Jan-23    
19-Jan-23    
19-Jan-23    
19-Jan-23    
19-Jan-23    
19-Jan-23    
19-Jan-23    
19-Jan-23    
19-Jan-23    
19-Jan-23    
18-Jan-23    
18-Jan-23    
18-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
17-Jan-23    
13-Jan-23    
13-Jan-23    
13-Jan-23    
13-Jan-23    
13-Jan-23    
13-Jan-23    
13-Jan-23    
13-Jan-23    
13-Jan-23    
12-Jan-23    
12-Jan-23    
12-Jan-23    
12-Jan-23    
12-Jan-23    
12-Jan-23    
12-Jan-23    
12-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
11-Jan-23    
10-Jan-23    
10-Jan-23    
10-Jan-23    
10-Jan-23    
10-Jan-23    
10-Jan-23    
10-Jan-23    
9-Jan-23    
9-Jan-23    
9-Jan-23    
9-Jan-23    
9-Jan-23    
9-Jan-23    
9-Jan-23    
9-Jan-23    
6-Jan-23    
6-Jan-23    
6-Jan-23    
6-Jan-23    
6-Jan-23    
6-Jan-23    
6-Jan-23    
5-Jan-23    
5-Jan-23    
4-Jan-23    
3-Jan-23    
3-Jan-23    
3-Jan-23    
3-Jan-23    
3-Jan-23    
3-Jan-23    
3-Jan-23    
3-Jan-23    
3-Jan-23    
29-Dec-22    
29-Dec-22    
29-Dec-22    
29-Dec-22    
28-Dec-22    
22-Dec-22    
7-Apr-22    
3-Mar-22    
3-Jan-23    
16-Dec-22    
15-Dec-22    
28-Nov-22    
14-Nov-22    
17-Oct-22    
3-Oct-22    
3-Oct-22    
21-Sep-22    
21-Sep-22    
13-Sep-22    
30-Aug-22    
14-Jul-22    
10-May-22    
7-Apr-22    
3-Mar-22    
3-Mar-22    
8-Feb-22    
11-Apr-22   180
4-Jan-2313-Mar-23   
3-Jan-2310-Mar-23   
29-Dec-229-Mar-23   
28-Dec-2214-Mar-23   
19-Dec-2213-Mar-23   
14-Dec-226-Mar-23   
14-Dec-2213-Mar-23   
14-Dec-2210-Mar-23   
8-Dec-221-Mar-23   
11-Nov-221-Feb-23   
9-Nov-2216-Feb-23   
4-Nov-226-Feb-23   
24-Oct-2214-Dec-22   
17-Oct-226-Dec-22   
6-Oct-2230-Jan-23   
6-Oct-2228-Nov-22   
5-Oct-2228-Nov-22   
3-Oct-2217-Nov-22   
3-Oct-2215-Nov-22   
16-Sep-2227-Oct-22  45
18-Aug-228-Nov-22   
9-Aug-2222-Sep-22  60
19-Jul-2219-Sep-22   
18-Jul-229-Sep-22   
18-Jul-2220-Sep-22   
18-Jul-2212-Sep-22  25
11-Jul-228-Sep-22  150
8-Jun-2217-Aug-22  25
7-Jun-2224-Aug-22  60
31-May-2216-Aug-22  30
31-May-2226-Jul-22  240
25-May-2228-Jul-22  25
23-May-2225-Jul-22   
20-May-2225-Jul-22  25
5-May-2215-Aug-22  25
20-Apr-2210-Aug-22  50
15-Apr-2221-Jun-22  45
12-Apr-2220-Jun-22  10
4-Apr-2223-Jun-22  180
22-Mar-221-Jun-22  55
11-Mar-2210-Jun-22   
7-Mar-2214-Jun-22  150
16-Feb-2216-May-22  25
10-Feb-225-May-22  25
10-Feb-229-May-22  25
2-Feb-222-May-22  45
20-Jan-2219-Apr-22  45
6-Jan-2228-Mar-22  25
21-Dec-223-Mar-233-Mar-23 25
16-Sep-2227-Oct-2227-Oct-22 45
14-Sep-221-Nov-221-Nov-22 90
25-Aug-2213-Oct-2218-Oct-22 100
12-Aug-2223-Sep-2223-Sep-22 20
9-Aug-2226-Sep-2226-Sep-22 60
22-Jul-2226-Sep-2229-Sep-22 240
14-Jul-2223-Sep-2223-Sep-22 240
12-Jul-227-Sep-227-Sep-22 90
24-Jun-2231-Aug-2231-Aug-22 90

Date is normal date table-

DateMonthNumMonthMonthLongYearMonthYearWeekSequenceNumWeek of Year
1/1/2022 0:001JanJanuary2022Jan-2211
1/2/2022 0:001JanJanuary2022Jan-2222
1/3/2022 0:001JanJanuary2022Jan-2222
1/4/2022 0:001JanJanuary2022Jan-2222
1/5/2022 0:001JanJanuary2022Jan-2222
1/6/2022 0:001JanJanuary2022Jan-2222
1/7/2022 0:001JanJanuary2022Jan-2222
1/8/2022 0:001JanJanuary2022Jan-2222
1/9/2022 0:001JanJanuary2022Jan-2233
1/10/2022 0:001JanJanuary2022Jan-2233
1/11/2022 0:001JanJanuary2022Jan-2233
1/12/2022 0:001JanJanuary2022Jan-2233
1/13/2022 0:001JanJanuary2022Jan-2233
1/14/2022 0:001JanJanuary2022Jan-2233
1/15/2022 0:001JanJanuary2022Jan-2233

@Anonymous   this is exactly what i was looking for!  thanks,  how did you create New request, Sent to, Posted calculated columns.  i was using this Dax below to create the calculated columns but it doesn't seem to be working.  I can  see the values as a measure but not as a column .  See attached sample data.  thanks

OneDash_0-1678891248906.png

 

 

OneDash_0-1678886264745.png

Thanks, It did worked for me to to do what i was looking for

Anonymous
Not applicable

Hi  ,

Please have a try.

New request column =
CALCULATE (
    COUNT ( 'Table'[DATE RECEIVED] ),
    FILTER ( 'Table', 'Table'[DATE RECEIVED] = EARLIER ( 'date'[Date] ) )
)

Please cancel the relationship between the tables.

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

 
One-Dash
Frequent Visitor

@amitchandak I'm not really good at PBI,  can you explain more pleae.  How will i create my InitStock? also which columns will be my Order/Sold? the table in above in my question is from excel which i used to populate manually and don't want to use anymore,  but hoping PBI can derive something similar.  Currently, I only have two tables.  

Date table and 

Invoice -  Ticket#, DateReceived, DateStarted, DateSentQA, DatePosted. example below

Ticket#DATE RECEIVEDDate StartedDate Sent to QDATE Posted
585979741/3/20224/28/20224/28/20225/12/2022
585924671/3/20222/2/20222/2/20222/3/2022
585938391/3/20224/20/2022null4/20/2022
585607411/3/20223/25/20223/25/20225/3/2022
585131171/4/20224/14/20224/14/20225/13/2022
584923561/4/20223/24/20223/24/20225/3/2022
585711871/4/20223/23/20223/23/20225/23/2022
584979241/4/20224/20/20224/20/20225/13/2022
586208271/5/20223/28/20223/29/20225/3/2022
585197341/5/20224/20/2022null4/20/2022
585321181/5/20223/24/20223/24/20225/3/2022
586195071/5/20224/11/20224/11/20225/19/2022
577653351/5/20223/25/2022null3/25/2022
586191721/5/20223/25/20223/25/20225/3/2022
585503881/5/20224/20/20224/20/20225/12/2022
amitchandak
Super User
Super User

@One-Dash , You have create cumulative inventory

 

example

Inventory / OnHand
[Intial Inventory] + CALCULATE(SUM(Table[Ordered]),filter(date,date[date] <=maxx(date,date[date]))) - CALCULATE(SUM(Table[Sold]),filter(date,date[date] <=maxx(date,date[date])))

 

or

 

Inventory / OnHand
CALCULATE(firstnonblankvalue('Date'[Month]),sum(Table[Intial Inventory]),all('Date')) + CALCULATE(SUM(Table[Ordered]),filter(date,date[date] <=maxx(date,date[date]))) - CALCULATE(SUM(Table[Sold]),filter(date,date[date] <=maxx(date,date[date])))

 

in your case, all might be cumulative

Power BI Inventory On Hand: https://youtu.be/nKbJ9Cpb-Aw

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.