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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
touseef2660
Helper I
Helper I

How to add a column number with max of previous rows in current column

I want to write a this formula in calculated column dax in power bi : A5+MAX($B$1:B4)

PBI issue.png

1 ACCEPTED SOLUTION

hi, @touseef2660 

it's a measure not a calculated column

if you want to make column try below

Column = 
var a = 'Power Bi sheet'[Index]
return
SUMX(
    FILTER('Power Bi sheet','Power Bi sheet'[Index]<=a),
    'Power Bi sheet'[Gross]
    )

 

Dangar332_0-1699554453709.png

 

View solution in original post

15 REPLIES 15
touseef2660
Helper I
Helper I


For the  formula you gave Measure 2 = CALCULATE( SUM('Table (4)'[Column1]), 'Table (4)'[Index]<=MAX('Table (4)'[Index]) )  WhatsApp Image 2023-11-09 at 10.38.53 PM.jpeg

Here commulative gross1 is also a calculated column. which is : if (capital structure[standard filed]="Yes",0,'capital structure'[value])

I think that why the circular dependency error is coming

touseef2660
Helper I
Helper I

Can I attach a power BI file here? 

hi, @touseef2660 

if you have no problem then attach here

I cant see the option to attach the power bi file

Hi, @touseef2660 

save your file on dropbox or drive or somewhere else

and provide link of file using link icon (see below image)

Dangar332_0-1699552000743.png

 

https://1drv.ms/f/c/0509e0cead042ba1/EhtU1pL9m5dDrIYQ30JQUdQB1MtMPTc8qQa9LQ2CyE3dww?e=TXE0jj 

You can find the files here. I tried your formula 

CALCULATE( SUM('Power Bi sheet'[Gross]), 'Power Bi sheet'[Index]<=MAX('Power Bi sheet'[Index]) )
But this is not giving the desired output

hi, @touseef2660 

it's a measure not a calculated column

if you want to make column try below

Column = 
var a = 'Power Bi sheet'[Index]
return
SUMX(
    FILTER('Power Bi sheet','Power Bi sheet'[Index]<=a),
    'Power Bi sheet'[Gross]
    )

 

Dangar332_0-1699554453709.png

 

Hello, 
With this Dax, it is giving wrong output if negative and zero value is there. For eg:

touseef2660_1-1699607918554.png

The output should be:

touseef2660_2-1699607956130.png

But it is giving:

touseef2660_3-1699607987976.png

 

hi, @touseef2660 

download PBIX file click HERE 
in there mention output with measure and  with column

Bro you are amazing. Thanks a ton!!.

It is giving the same numbers 

touseef2660_0-1699552803559.png


Where as the output should be as below:

touseef2660_1-1699552851620.png

@lbendlin 



Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

You can find the files here : https://1drv.ms/f/c/0509e0cead042ba1/EhtU1pL9m5dDrIYQ30JQUdQB1MtMPTc8qQa9LQ2CyE3dww?e=TXE0jj

There are 2 files one is excel and other is power bi. In excel the 2nd sheet has the desired output. In first sheet it is the data which I have uploaded on power bi sample file. 

Thanks

Dangar332
Super User
Super User

Hi, @touseef2660 

put your image erroe image here
or provide some  sample data

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.