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
fabiolamelo
Helper II
Helper II

CALCULATE AVERAGE ACCUMULATE PER MONTH WITH COLUMNS RULES

Hi everyone,

 

I`m trying to find a solution to calculate the average of the accumulative stock by month.

I have one transaction table that gives me the following information:

Tran Date Qty Stock Type DRCR TRAN_SRC
31/08/2020 1,348.00 PEN 1 FA
3/09/2020 3,060.00 PEN 1 LB
8/09/2020 2,250.00 PEN 1 LB
12/09/2020 2,250.00 PEN 1 LB
16/09/2020 4,500.00 PEN 1 LB
29/09/2020 4,000.00 PEN 1 LB
3/10/2020 3,000.00 PEN 1 LB
12/10/2020 4,000.00 PEN 1 LB
22/10/2020 4,000.00 PEN 1 LB
2/11/2020 4,000.00 PEN 1 LB
12/11/2020 4,000.00 PEN 1 LB
19/11/2020 4,000.00 PEN 1 LB
26/11/2020 4,000.00 PEN 1 LB


If column DRCR is equal 1 and TRAN_SRC is different than "AP",
I need to find a way to consider the following rules:

1 - calculate the total accumulative qty by month and stock type

2 - Then the total monthly average by stock type

 

So the result that I expected is the following below

Month                  | Qty Sum |   Average Qty Year | Average Qty last 2 month( nov / oct) | Average Qty last 3 month(nov / oc/ sept)
november           | 16,000.00 |                                 | 13,500.00                                       |            14,353.33
oct                       | 11,000.00 |
september        | 16,060.00|
august                | 1,348.00 |    11,102.00 |

 

Qty Sum Average Qty Year Average Qty last 2 month( nov / oct) Average Qty last 3 month(nov / oc/ sept)
november 16,000.00 13,500.00 14,353.33
oct 11,000.00
september 16,060.00
august 1,348.00 11,102.00

 


 I`ve tried to use the following logic but I don't get the right result.

SUMMARIZECOLUMNS(
table[STOCK_CODE],
table_DATE[Year],
table_DATE[month],
table[QTY],
"Qty_Summary",
VAR P01 =
CALCULATE (
SUM(table[QTY]),
FILTER (
table,
table[DRCR] = "01"
&& table[TRAN_SRC] <> "AP"
)
)
VAR Result = P01
RETURN
Result

)

Can you please help me?

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Powerbiiiiii90
New Member

Hi everyone,

Despite so many time of trying I yet get the result as wanted. Can do me favour on below result needed ?

 

1) Stock in Whs today

 

2) Average consumption for past 3 month

 

Entry NoEntry TypeItemPosting DateCreated DateQuantityOwnership
19263074SalesCSOYA2/1/20242/1/2024 3:45-58A
19263127SalesCSOYA2/2/20242/1/2024 3:46-33A
19263281SalesCSOYA2/1/20242/1/2024 3:48-18A
19300901SalesWATER3/2/20243/1/2024 3:02-35A
19300911SalesCSOYA3/1/20243/1/2024 3:04-36A
19301049SalesCSOYA3/1/20243/1/2024 3:06-4A
19301095SalesWATER3/1/20243/1/2024 3:08-9A
19341135SalesCSOYA4/2/20244/1/2024 2:32-4B
19341159SalesWATER4/1/20244/1/2024 2:33-9B
19341371SalesWATER4/1/20244/1/2024 2:51-3B
19341411SalesWATER4/2/20244/1/2024 2:53-3B
19341857SalesCSOYA4/1/20244/1/2024 3:03-22B
19341869SalesCSOYA3/1/20244/1/2024 3:04-3A
19342266SalesWATER4/2/20244/1/2024 3:35-36A
19342309SalesWATER4/1/20244/1/2024 3:36-7A
19342386SalesCSOYA4/1/20244/1/2024 3:38-20A
19378986SalesCSOYA5/1/20245/1/2024 4:29-7B
19379035SalesWATER5/2/20245/1/2024 4:30-15A
19379067SalesCSOYA5/2/20245/1/2024 4:31-15A
19379098SalesWATER5/1/20245/1/2024 4:33-54A
19379126SalesCSOYA5/1/20245/1/2024 4:34-26A
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @Ashish_Mathur  your solution helped me a lot. 

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
V-pazhen-msft
Community Support
Community Support

@fabiolamelo 
You can just create the following measure for accumulative sum with filters, the [month] in bold must be month number not name.

 

Measure = CALCULATE ( SUM(table[QTY]), FILTER (table, table[DRCR] = "01" && table[TRAN_SRC] <> "AP"), FILTER(ALL(table), [Month]<=MAX([Month]))


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

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.