cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Anonymous
Not applicable

## skip a row and rewrite the same values from 2nd row

Hello, I have a small question. I have a column X with 1 2 3 4 5 6 as numbers and i want a column to be added with Y  as the same as X but 1st row should be skipped in Y when comparing to X. Like the following one.

X      Y

1

2      1

3      2

4      3

5      4

6      5

6

c

Can anyone please suggest me the solution with a DAX code or else anything?

1 ACCEPTED SOLUTION
Community Support

Hi @Anonymous ,

Test the below:

``Table2 = DISTINCT(UNION( SELECTCOLUMNS('Table',"X",'Table'[X]),SELECTCOLUMNS('Table',"X",0)))``
``````Y = IF (
Table2[X]=0,
CALCULATE(MAX(Table2[X]),ALL(Table2)),
IF (
CALCULATE (
MAX ( 'Table2'[x] ),
FILTER ( ALL ( Table2 ), Table2[x] < EARLIER ( Table2[X] ) )
) = 0,
BLANK (),

CALCULATE (
MAX ( 'Table2'[x] ),
FILTER ( ALL ( Table2 ), Table2[x] < EARLIER ( Table2[X] ) )
)
)
)
``````

Best Regards

Lucien

Community Support

Hi @Anonymous ,

Test the below:

``Table2 = DISTINCT(UNION( SELECTCOLUMNS('Table',"X",'Table'[X]),SELECTCOLUMNS('Table',"X",0)))``
``````Y = IF (
Table2[X]=0,
CALCULATE(MAX(Table2[X]),ALL(Table2)),
IF (
CALCULATE (
MAX ( 'Table2'[x] ),
FILTER ( ALL ( Table2 ), Table2[x] < EARLIER ( Table2[X] ) )
) = 0,
BLANK (),

CALCULATE (
MAX ( 'Table2'[x] ),
FILTER ( ALL ( Table2 ), Table2[x] < EARLIER ( Table2[X] ) )
)
)
)
``````

Best Regards

Lucien

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors