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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

Accumulated by dates

Hello community, I hope you can help me with this question

I am trying to look for the accumulated of our stock, without emabargo to program in DAX I am not the best, I could only do this Measure that takes the difference between the inputs and the processed:

PROD TPDM= Inputs

LAFI INPUT = Outputs

Differences = CALCULATE(COUNT('PROD TPDM'[DATE])-COUNT('LAFI ENTRY' [DATE]))
Here's what it does
Kddk852_0-1656337710176.png

However I want you to show the accumulated, that is:

MonthinoutDifference*stock
January27,15225,1462,0062,006
February26,04322,4223,6215,627
March29,27033,725-4,4551,172
April31,95829,1812,7773,949
May28,82029,555-7353,214
June409354553,269

*The Difference column I don't want to appear

I hope you can help me

4 REPLIES 4
JChai
Frequent Visitor

Hello @Syndicate_Admin,

 

I believe that you are talking about cumulative sum. Here's how you can do it with DAX:

 

CUM_DIFF = 
CALCULATE (
SUM('TABLE'[Diferencias]),
FILTER(ALL('TABLE'),
'TABLE'[MONTH NUM] <= EARLIER ( 'TABLE'[MONTH NUM] )
)
)

 

Notice that I have generated an additional column `MONTH NUM` which help in sorting the `MONTH` (Text) column. Below is how my final table looks like.
JChai_0-1656344031670.png

Here are the link that you might find helpful:  Solved: Cumulative Sum, DAX - Microsoft Power BI Community

 

Hope this help!

 

Best,

JKC

It is just what I want to do, without emabargo, my data is not separated by months, the data is individual data and is grouped depending on the month, as seen in the photo, try to make a column with the number of the month, but I do not know if it works that way

Kddk852_0-1656352112887.png

And this columa I made with a Month

Kddk852_2-1656352178118.png

It is also worth mentioning that the production and the entries are in two separate tables

Kddk852_3-1656352218408.png

@Syndicate_Admin 

Yes, it can be done. You just need to make sure that you have define the right schema relationships for working with both LAFI & TPDM tables. A simple illustration of this schema is presented as below.

JChai_0-1656363633317.png

The results presented from the simple tables in Power BI is shown as below.

JChai_2-1656364272949.png

The DAX formula uses are the same without much complications, thus, you should be able to handle easily. 

Best,

JKC

---

FYI: LAFI table has 141 rows & TPDM table has 145 rows.

amitchandak
Super User
Super User

@Syndicate_Admin , I think you need something like this

 

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

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

 

 

How to work with more than one date

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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