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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Rehansaeed2024
Frequent Visitor

Excel Calc in Power BI

HOw to code this excel formula in Power BI SUMPRODUCT(C$2:C3,(1-$K$4)^(ROW(C3)-ROW(C$2:C3)))

 

The row index is caclulated on the fly based on teh user selection so I do have the Row index aleready generated using the below DAX.

 

Product IDOrder Date Product Cost Numerator (Expected)Denominator (DONE)
600554231/2/2024            8,868,094.35  
600561341/2/2024            7,629,201.4316,184,984.961.964783
600585141/2/2024            5,618,481.3321,233,473.952.895589237
600558451/5/2024          13,441,244.8833,926,932.063.793615271
600563801/5/2024            2,053,174.3534,785,289.634.660015522
600591831/5/2024            9,238,017.7342,798,261.505.495903755
600583771/10/2024            9,470,897.0650,761,917.046.302354513
600519521/11/2024            9,820,500.2558,794,716.897.080404494
     
Denominator Excel Formula  = SUMPRODUCT((0.964783)^(ROW(C3)-ROW(C$2:C3))) Working ffine in PBI wthe below DAX Measure
VAR Alpha = 0.964783   
VAR CurrentIndex =[Row Index_Line_Items] This Is a measure 
     
-- first OrderIndex in the current filter context (e.g., current month, product set, etc.)
VAR MinIndex =    
    CALCULATE (   
          MINX ( ALLSELECTED('Table A'), [Row Index_Line_Items] ) 
            
    )    
     
VAR N = CurrentIndex - MinIndex+1  
RETURN    
IF (    
    ISBLANK ( CurrentIndex ) || ISBLANK ( MinIndex ) || N <= 0, 
    BLANK (),    
    ( 1 - POWER (Alpha, N ) )  / ( 1 -Alpha )  
   )    
     
Numerator Formula    = SUMPRODUCT(C$2:C3,(1-$K$4)^(ROW(C3)-ROW(C$2:C3))) 
??    
19 REPLIES 19
Khushidesai0109
Super User
Super User

Hello @Rehansaeed2024 

Try this



Numerator :=
VAR Alpha = 1 - 0.964783 -- If K4 = 0.964783, adjust as needed
VAR CurrentIndex = [Row Index_Line_Items]

RETURN
IF(
ISBLANK(CurrentIndex),
BLANK(),
CALCULATE(
SUMX(
ADDCOLUMNS(
'Table A',
"Weight",
POWER(
Alpha,
CurrentIndex - [Row Index_Line_Items]
),
"WeightedValue",
'Table A'[Product Cost] *
POWER(
Alpha,
CurrentIndex - [Row Index_Line_Items]
)
),
[WeightedValue]
),
FILTER(
ALLSELECTED('Table A'),
[Row Index_Line_Items] <= CurrentIndex
)
)
)

Proud to be a Super User!!
v-sshirivolu
Community Support
Community Support

Hi @Rehansaeed2024 ,

I've recreated your entire scenario in a new sample .pbix file to verify the behavior. After setting up the same tables, adding the Row Index, and applying the decay based numerator and denominator logic, I was able to reproduce the exact expected output on my side. Both the running numerator calculation and the denominator values are working correctly when the DAX measures are created under the LineItems table.

This confirms that the logic you are using is valid, and Power BI calculates the decayed SUMPRODUCT pattern exactly as intended once the Row Index and Alpha value are set up properly. For your reference, I've attached the working .pbix file so you can compare it with your model and follow the steps used to get the final result.

 

Here is a link to the Excel File.

https://docs.google.com/spreadsheets/d/1IVujWmZuJfPLGEFzLywzE4eCqiTiTUL3/edit?usp=drive_link&ouid=10...  

 

Here is the link to the sample PBIX file using this EXcel. Denominator Column I am able to get it working struggling with the numerator column.

 

https://s3-project-rehan.s3.us-east-2.amazonaws.com/Sample_PBIX.pbix

 

 

Hi,

In cell B2 of Table A worksheet, shouldn't the date be Jan 1, 2025.  Also, are all dates in mm/dd/yy format?


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

Hi @Rehansaeed2024  ,

To reproduce Excel’s decayed SUMPRODUCT logic in Power BI, I first created a stable Row Index column using RANKX in Table A and then brought it into Table B using Row Index_TableB = RELATED('Table A'[Row Index]). This gives Power BI the row-by-row context that Excel gets from ROW(). The denominator was already correct using Alpha = 0.964783. The numerator, which corresponds to SUMPRODUCT(C$2:C3, Alpha^(ROW(C3)-ROW(C$2:C3))), is implemented in DAX by summing all previous Product Cost values with decay based on the row distance:

Numerator_Decayed :=
VAR Alpha = 0.964783
VAR CurrentIndex = SELECTEDVALUE('Table B'[Row Index_TableB])
VAR MinIndex = CALCULATE(MINX(ALLSELECTED('Table B'), 'Table B'[Row Index_TableB]))
RETURN
IF(
ISBLANK(CurrentIndex) || ISBLANK(MinIndex),
BLANK(),
CALCULATE(
SUMX(
FILTER(ALLSELECTED('Table B'), 'Table B'[Row Index_TableB] <= CurrentIndex),
'Table B'[Product Cost] *
POWER(Alpha, CurrentIndex - 'Table B'[Row Index_TableB])
)
)
)
The final weighted output is:

Weighted_ProductCost :=
DIVIDE([Numerator_Decayed], [Denominator])
Once the Row Index column and these measures are applied, the Numerator and Weighted values match Excel’s SUMPRODUCT output exactly, fully solving the translation of the Excel formula into Power BI DAX.

 

Getting incorrect Numerator Numbers.

Product IDOrder DateSum of Product CostDenominatorNumerator_Decayed
600554231/2/2024 0:008868094  
600561341/2/2024 0:0076292011               66,139,611.38
600585141/2/2024 0:0056184811.964783               63,810,372.69
600558451/5/2024 0:00134412452.895588               61,563,162.79
600563801/5/2024 0:0020531743.793613               59,395,092.89
600591831/5/2024 0:0092380184.660012               57,303,375.90
600583771/10/2024 0:0094708975.495899               55,285,322.91
600519521/11/2024 0:0098205006.302348               53,338,339.69

Hi @Rehansaeed2024 ,

I've attached a PBIX file to help you verify the calculation. It includes a synced Row Index so Excel and Power BI follow the same row order, the full NumeratorDecayed measure, and a table showing the correct results. Once you open the file and view the sorted table, you’ll see the Numerator matches Excel because the decay logic depends on row order.

Please find below attached .pbix file for your reference.

Denominator is working as expected but the Numerator_Decayed is giving "Query Exceeded Availabe Resources"

and If I am trying a smaller data set I am getting 0.00 for all rows

Hi @Rehansaeed2024 ,
Thanks for confirming that the results are matching in the reference PBIX. This confirms that the Excel decayed
SUMPRODUCT logic is correctly implemented in Power BI using DAX.

The issues you are facing in your actual PBIX are not due to the formula, but mainly because of model structure and data size. The circular dependency error usually comes when a measure like Numerator_Decayed is used directly or indirectly inside a calculated column, or when the Row Index itself is created using measures. In the working PBIX, the Row Index is a simple calculated column, and both Numerator and Denominator are measures only, which avoids this issue.

The “Query exceeded available resources” message happens when the SUMX + FILTER logic runs over a very large or highly detailed dataset. In such cases, the data grain or Row Index scope needs to be reduced to improve performance.

When you see 0.00 values for smaller datasets, it usually means the Row Index is not stable or the table is not sorted in the same order as Excel before assigning the index. Since Excel’s ROW() depends on position, sorting is very important.

Please use the attached PBIX as a reference for how the Row Index and measures should be structured. Once the same separation and sorting are applied in your actual model, the Numerator_Decayed will behave exactly the same as Excel.

 

Hi @Rehansaeed2024 ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Hi @Rehansaeed2024 ,

I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you

 

I see u are able to match the results. BUt I am trying to replicate the exact in my actual data pbix file I am getting an error message A circular dependency was detected: shop_visit_line_items[Numerator_Decayed]. Denominator is working as expected.

I see u are able to match the results. BUt I am trying to replicate the exact in my actual data pbix file I am getting an error message A circular dependency was detected: Table B[Numerator_Decayed]. Denominator is working as expected.

 

Now for the numerator Decayed I am getting "Query Has exceeded the available resources" messages for the Table Visual.

YOur results are not matching as per my Excel file.

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the MS Excel file with your formulas already written there so that i can clearly udnerstand your logic.


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

Hi @Rehansaeed2024 ,

DAX MEASURE  Numerator Equivalent

 

Assuming:

 

[Row Index_Line_Items] = your sequential row index measure

 

'Table A'[Product Cost] = C column

 

Alpha = 0.964783

 

DAX measure.

 

Numerator =

VAR Alpha = 0.964783

VAR OneMinusAlpha = 1 - Alpha

 

VAR CurrentIndex =

    [Row Index_Line_Items]

 

VAR MinIndex =

    CALCULATE(

        MINX(ALLSELECTED('Table A'), [Row Index_Line_Items])

    )

 

RETURN

IF(

    ISBLANK(CurrentIndex) || ISBLANK(MinIndex),

    BLANK(),

    CALCULATE(

        SUMX(

            FILTER(

                ALLSELECTED('Table A'),

                [Row Index_Line_Items] <= CurrentIndex

            ),

            'Table A'[Product Cost] *

                POWER(

                    OneMinusAlpha,

                    CurrentIndex - [Row Index_Line_Items]

         

      )

        )

    )

)

 

If my response as resolved your issue please mark it as solution and give kudos.

vivien57
Power Participant
Power Participant

Hello @Rehansaeed2024 ,

 

Try this :

VAR Alpha = 0.964783
VAR CurrentIndex = [Row Index_Line_Items]

VAR MinIndex =
    CALCULATE (
        MIN ( 'Table A'[Row Index_Line_Items] ),
        ALLSELECTED ( 'Table A' )
    )

RETURN
SUMX (
    FILTER (
        ALLSELECTED ( 'Table A' ),
        'Table A'[Row Index_Line_Items] >= MinIndex
            && 'Table A'[Row Index_Line_Items] <= CurrentIndex
    ),
    'Table A'[Product Cost]
        * POWER (
            (1 - Alpha),
            CurrentIndex - 'Table A'[Row Index_Line_Items]
        )
)

 

Row Index_Line_Items must be unique

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.