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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
pranays2
Frequent Visitor

Create a column to get values from other column but from 2nd row

Hi,

 

I want to create a new column (B) where the values should be from already existing column (A) but in the new column (B) i want the values to start from 2nd row of col (A).

 

 PBI Doubt.PNG

Kindly let me know if there is any formula or DAX to do this 

2 ACCEPTED SOLUTIONS
v-yiruan-msft
Community Support
Community Support

Hi @pranays2 ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Add one index column in Power Query Editor

yingyinr_2-1674199873298.png

2. Create a calculated column as below to get it

Column B = 
VAR _nextindex =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        FILTER ( 'Table', 'Table'[Index] > EARLIER ( 'Table'[Index] ) )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[Column A] ),
        FILTER ( 'Table', 'Table'[Index] = _nextindex )
    ) + 0

yingyinr_3-1674199942296.png

In addition, you can refer the following links to get it.

Power BI: Get value from next row

yingyinr_0-1674199363238.png

Fast and easy way to reference previous or next rows in Power Query or Power BI

yingyinr_1-1674199446803.png

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

View solution in original post

Hi @pranays2 ,

I updated my sample pbix file(see the attachment) with creating a measure, please check if that is what you want.

Measure = 
VAR _selindex =
    SELECTEDVALUE ( 'Table'[Index] )
VAR _selcolumnA =
    SELECTEDVALUE ( 'Table'[Column A] )
VAR _nextindex =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] > _selindex )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[Column A] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] = _nextindex )
    ) + 0

yingyinr_0-1675132996722.png

Best Regards

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

View solution in original post

3 REPLIES 3
pranays2
Frequent Visitor

Thanks for the reply but the result value which i want is a measure so i'm not able to get it correctly using the above method can you let me know if there is a way to do this for measure

Hi @pranays2 ,

I updated my sample pbix file(see the attachment) with creating a measure, please check if that is what you want.

Measure = 
VAR _selindex =
    SELECTEDVALUE ( 'Table'[Index] )
VAR _selcolumnA =
    SELECTEDVALUE ( 'Table'[Column A] )
VAR _nextindex =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] > _selindex )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[Column A] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] = _nextindex )
    ) + 0

yingyinr_0-1675132996722.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

Hi @pranays2 ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Add one index column in Power Query Editor

yingyinr_2-1674199873298.png

2. Create a calculated column as below to get it

Column B = 
VAR _nextindex =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        FILTER ( 'Table', 'Table'[Index] > EARLIER ( 'Table'[Index] ) )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[Column A] ),
        FILTER ( 'Table', 'Table'[Index] = _nextindex )
    ) + 0

yingyinr_3-1674199942296.png

In addition, you can refer the following links to get it.

Power BI: Get value from next row

yingyinr_0-1674199363238.png

Fast and easy way to reference previous or next rows in Power Query or Power BI

yingyinr_1-1674199446803.png

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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