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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Den-iska
Regular Visitor

Closest lesser

Sorry for my English, first.
I have a Column (Integer), lets say Column [A], numbers in rows are unique.

Seems that all I need is to create another Column [B] and put there numbers which are taken from Column [A], but are closest lesser than numbers in Column [A] in respected rows.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Den-iska ,

 

Refer this formula.

Column = CALCULATE(MAX('Table'[Column1]),FILTER('Table','Table'[Column1]<EARLIER('Table'[Column1])))

4.PNG

 

Best Regards,

Jay

View solution in original post

3 REPLIES 3
Den-iska
Regular Visitor

 I have a column like this

Den-iska_0-1620986735095.png

And i need to add column like this:

Den-iska_1-1620986819975.png

So latest row in Column B is 12 because 12 is closest lesser to 13 which is in the same row in Column A. But on one row abowe there is a 10, because there is no 11 in Column A.
(images are from Excel, but I need it to be done in DAX).
Thanks.

Anonymous
Not applicable

Hi @Den-iska ,

 

Refer this formula.

Column = CALCULATE(MAX('Table'[Column1]),FILTER('Table','Table'[Column1]<EARLIER('Table'[Column1])))

4.PNG

 

Best Regards,

Jay

amitchandak
Super User
Super User

@Den-iska , I am not clear with the need.

See if new column can help

new column =
var _min = maxx(filter(Table, [columnA] < earlier([columnA])),[columnA])
var _max = minx(filter(Table, [columnA] > earlier([columnA])),[columnA])
return
if(_max -[columnA] > [columnA] - _min , _min, _max)

 

 

OR

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.