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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
MKushpil
Regular Visitor

Dynamic SUMIFS function into calculated column by DAX

Dear friends, hello!

My task is to create a 100,000 line pricing simulation. Unfortunately, excel cannot handle this amount. I tried to do it through DAX but I lack knowledge. Is it possible to make an analogue of such a formula?

 

I need to creat dynamic sumifs function in "calculated" column. Here is a fairly simple algorithm, but due to its massiveness, I cannot apply it in excel. I will be very grateful for help.

 

Снимок.PNG

11 REPLIES 11
amitchandak
Super User
Super User

@MKushpil , The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format?
Appreciate your Kudos.


Dear @amitchandak,

thank you for your feedback! Sure, file attached.

 

My task is simulate price for 221 and 231 Movement Type [ Column E] in Value TranCurr Simulation column [ Column H].

 

I'll try to explane on H5 example.

If Movement type is positive then take Value TranCurr else 

SUMIFS (Sum range = $H$1:H4 = all previous rows; Material range = $A$1:A4; Material = A5 ... )

In result we have calculation: ( ( 2431082,5 - 799260 ) / (146 - 48) * - 48 ) = -799260 (H5).

 

The main problem is my SUMIFS function has dynamic range in my calculated column (all previous rows). And on every second row my range gets bigger. I have 100k rows and my Excel cannot make this function. In powerpivot I also don't know, how to make it by DAX, because there I have dependecy error (link on calculated column).

 

https://yadi.sk/i/TkOMfHXVq2R0ZA

Hi,

In For quite many rows, the numbers in column H match the numbers in column C.  Where they do not, the differences are very small.  So my simple lay person question is that why do you need the complicated SUMIFS() function when in face you are getting the same numbers which are already present in column C.


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

Dear @Ashish_Mathur,

You are right, in my current example I have the same figuers in Column C and my simulation Column H. I did this to test the behavior of the transactions when calculating the weighted average.
Let's go a little further to H7.

 

I decide that the purchase from 04/03/2019 160 pieces should have an account assignment not T.01.03.01, but T.01.03.02 (it's error).

It means for H7 calculation that we no longer have additional 4225828,46 in the numerator and additional 160 pieces in the denominator.

 

So, calculation for H7 was:
( 2431082,5 - 799260 + 4225828,46 ) / ( 146 - 48 + 160 ) * - 1 = - 22704,07 - before changing WBS Element

And then

( 2431082,5 - 799260 ) / ( 146 - 48) * - 1 = - 16651,25 - after changing WBS Element

My task to understand this delta (before and after WBS changing). But It's possible for me only by, as you said, the complicated SUMIFS() function with dynamic range.

 

 

@MKushpil,

 

Not sure i understand your logic, the purchase from 04/03/2019 has a positive Total Quantity, which bypasses the SUMIF logic, value of H is 4,225,828.46. The SUMIF only deals with negative Total Quantities. How do you determine that the values are assigned to the incorrect account and if we are doing an account reassignment, could we not just update the WBS Element? then do a straight sum using the reassigned WMS Element to group by.

 

Sorry if I am being dense.

 

Richard



I hope this helps,
Richard

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

Proud to be a Super User!


Dear @richbenmintz,

My example shows the fact that there is in SAP. But for 4,225,828.46 account is worng (It's my personal de facto decision, not formula result). This purchase in euro, that's why I need change account and then in my second transaction I will have negative effect, because my fact weighted average bigger than should be. And every previous buy/write off transaction is in formula, therefore, I don't know how to avoid it.(

@MKushpil,

 

Sorry but I think I am at a loss here, not sure i understand exactly what you are doing and pretty sure that the sum of the sum of the same calculation is not supported. If you can come up with an alternate way to weight and sum your data I could try again.

 

Sorry

 

Richard



I hope this helps,
Richard

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

Proud to be a Super User!


@MKushpil ,

In all cases in your sample data the Value TranCurr Simulation is the same as the Value Tran, are you sure the formula provides the values you want. If not is there are different way to generate the simulation withour having a recursive sumif of the same column?



I hope this helps,
Richard

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

Proud to be a Super User!


Dear @richbenmintz ,

As I already answered, you are right, in my current example I have the same figuers in Column C and my simulation Column H. I did this to test the behavior of the transactions when calculating the weighted average. How I understand, I cannot avoid this recursive sumif of the same column. If somebody have any ideas, I'll be happy!)

 

 

Hi @MKushpil,

 

I guess what i am trying to understand is, are you able to derive the simulation without summing up the sums in colum H. The dynamic range is not a problem the self referencing sum is the problem



I hope this helps,
Richard

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

Proud to be a Super User!


Hi @MKushpil

 

Thanks for providing the sample data and excel doc. let me see if i can create a formula for you.



I hope this helps,
Richard

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

Proud to be a Super User!


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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