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
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
v-luwang-msft
Community Support
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] ) )
        )
    )
)

vluwangmsft_0-1654845938415.png

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

1 REPLY 1
v-luwang-msft
Community Support
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] ) )
        )
    )
)

vluwangmsft_0-1654845938415.png

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

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