cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors