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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to round a number from a specific date

Hi,

 

I need to roundup a number, but only from June onwards. For the other previous months of 2020, I don't want it to be rounded. I would like to do this within Power Query.

 

It's possible?

 

Example:

Capturar.JPG

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Hi @Anonymous - use this formula:

 

= if [Date] > #date(2020,5,31) then Number.Round([Value], 1) else [Value]

 

Just change the Number.Round() function to round to the number of decimal places you want, and adjust the #date() function as necessary. This will round all dates after May 31, 2020 to 1 decimal place, and for all other values, it will keep the original.

edhans_0-1605626670061.png

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

Hi @Anonymous - use this formula:

 

= if [Date] > #date(2020,5,31) then Number.Round([Value], 1) else [Value]

 

Just change the Number.Round() function to round to the number of decimal places you want, and adjust the #date() function as necessary. This will round all dates after May 31, 2020 to 1 decimal place, and for all other values, it will keep the original.

edhans_0-1605626670061.png

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Thank you @edhans. This will work for me, but is it possible to do this without creating a new column?

 

I'm sorry if my question is so basic, but I'm still learning M Language.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors