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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

Replacing the two last element of a list by a blank

Hello!

Like written in the subject, I would like to replace the two last elements of my measure by a blank. Do you know if it's possible? and if it is, how can I do it?

Thank you

Have a nice day!

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Try the following formula:

RowsNum = 
COUNTX(
    ALLSELECTED('Table'),
    'Table'[month_year]
)

 Then modify 9 -> [RowsNum]-1, 8 -> [RowsNum]-2...

 

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

8 REPLIES 8
amitchandak
Super User
Super User

@Anonymous , One way is to remove the last 2 items like

List.FirstN(MyList, List.Count(MyList -2))

 

may add another list to it

List.Combine(List.FirstN(MyList, List.Count(MyList -2)),{,})

List.Combine(List.FirstN(MyList, List.Count(MyList -2)),{0,0})

 

or

 

List.Combine(List.FirstN(MyList, List.Count(MyList -2)),{"",""})

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you @amitchandak ,

but the function didn't work the LIST. didn't got recognize by Power bi. Is it dax?

Hi @Anonymous ,

 

This is a screenshot of my test.

 

image.png

The value of a measure is context dependent. What is your DAX? What kind of visual do you want to put the measure in, and what is its context?

 

Best Regards,
Winniz

Anonymous
Not applicable

Hello, Thank you for your answer

I got 12 measure with value in it. I would like for the first measure to keep all my element, the second one to replace by a blank the last element, for the third replace the two last element, the fourth replace the 3 last element...

By doing this I will have a kind of triangle in my report.

Initially I got a triangle of value and I would like to do the cumulative sum of this triangle. And When I do it I got no longer a triangle of value because it sum for all the column. And as in my previous triangle I got blank when my value is 0 so I cannot use an if condition. I put a screen of my problem maybe it will help to understant my issues.

PatVi_1-1621841652153.png

Best regards

Thomas

 

 

Hi @Anonymous ,

 

Try the following formula:

 

R1 = 
CALCULATE(
    [M0]+[M1],
    TOPN( 9, ALLSELECTED('Table'[MonthNo_year]), 'Table'[MonthNo_year], ASC )
)
R2 = 
CALCULATE(
    [M0]+[M1]+[M2],
    TOPN( 8, ALLSELECTED('Table'[MonthNo_year]), 'Table'[MonthNo_year], ASC )
)
R3 = 
CALCULATE(
    [M0]+[M1]+[M2]+[M3],
    TOPN( 7, ALLSELECTED('Table'[MonthNo_year]), 'Table'[MonthNo_year], ASC )
)
R4 = 
CALCULATE(
    [M0]+[M1]+[M2]+[M3]+[M4],
    TOPN( 6, ALLSELECTED('Table'[MonthNo_year]), 'Table'[MonthNo_year], ASC )
)
R5 = 
CALCULATE(
    [M0]+[M1]+[M2]+[M3]+[M4]+[M5],
    TOPN( 5, ALLSELECTED('Table'[MonthNo_year]), 'Table'[MonthNo_year], ASC )
)

image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Anonymous
Not applicable

Thank you, the only thing is that you write topn(7...) or topn(9) but my number of line might change and if I enter 7 or 9 it wouldn't be a triangle anymore. There isn't a formula like topn(-1...) to only  delete the last one? Or maybe I could count the number of the measure M0 and then do (numberlineofMO-1) or minus 2...?

Hi @Anonymous ,

 

Try the following formula:

RowsNum = 
COUNTX(
    ALLSELECTED('Table'),
    'Table'[month_year]
)

 Then modify 9 -> [RowsNum]-1, 8 -> [RowsNum]-2...

 

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Anonymous
Not applicable

Thank you its working!!

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors