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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Vaibhav3008
Frequent Visitor

Iterative dax column

Hi All,

I need to build a dynamic column with iterative values as below. I already have "To be added value" and "Inventory Value". Need to build the "Projection" column through dax. Please help on how to get to this result:

Vaibhav3008_0-1682393343669.png

 

Any help would be great. Thanks!

1 ACCEPTED SOLUTION
barritown
Super User
Super User

Hello @Vaibhav3008,

 

If you can add an additional column called "row number", your problem may be solved like this:

barritown_0-1682406637496.png

Here's the [DAX] code in the text format for convenience:

projection = 
VAR current_row_number = [row number]
VAR last_inv_value_index = MAXX ( FILTER ( ALL ( data ), NOT ( ISBLANK ( data[inventory value] ) ) ), [row number] ) 
VAR base = LOOKUPVALUE ( data[inventory value], data[row number], last_inv_value_index )
VAR surplus = CALCULATE ( SUM ( data[to be added value] ), ALL ( data ), data[row number] > last_inv_value_index, data[row number] <= current_row_number )
VAR result = IF ( ISBLANK( data[inventory value] ), base + surplus, BLANK () )
RETURN result

 If a new column is not an option, you will need a more complex solution.

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

View solution in original post

2 REPLIES 2
Vaibhav3008
Frequent Visitor

Thanks for the help. It's working!

barritown
Super User
Super User

Hello @Vaibhav3008,

 

If you can add an additional column called "row number", your problem may be solved like this:

barritown_0-1682406637496.png

Here's the [DAX] code in the text format for convenience:

projection = 
VAR current_row_number = [row number]
VAR last_inv_value_index = MAXX ( FILTER ( ALL ( data ), NOT ( ISBLANK ( data[inventory value] ) ) ), [row number] ) 
VAR base = LOOKUPVALUE ( data[inventory value], data[row number], last_inv_value_index )
VAR surplus = CALCULATE ( SUM ( data[to be added value] ), ALL ( data ), data[row number] > last_inv_value_index, data[row number] <= current_row_number )
VAR result = IF ( ISBLANK( data[inventory value] ), base + surplus, BLANK () )
RETURN result

 If a new column is not an option, you will need a more complex solution.

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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