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

Calculate Month from Number of Days

Hello,

 

I have a column in the dataset that specifies the number of days(num_ofDays) which is of the type integer.

I'm trying to create a new column called month that lets me determine the month based on number of days.

 

The formula I'm trying to use is Ceiling(num_ofDays/30.5, 1)

 

Using this formula causes Power BI to throw an error & hangup & lose all progress on reports. The error Im getting is 

Unable to cast object of type System.Decimal to System.char
 
I tried replacing Ceiling with Round & Integer & they work just fine except that I'm not really getting the correct numbers.
Is there anything I'm missing?
 
Thanks,
Samantha
1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@sam245gonsalves 

This could be a data conversion issue, check your data source and the data types of the columns try to do it on a small sample of your data.

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @sam245gonsalves 

 

You may try the following calculated column to see if it works.

M = ROUNDUP([NumOfDays]/30.5,0)

 

Result:

b1.png

 

Best Regards

Allan

 

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

Fowmy
Super User
Super User

@sam245gonsalves 

This could be a data conversion issue, check your data source and the data types of the columns try to do it on a small sample of your data.

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hey @Fowmy 

 

Thanks, I tried the above but it still causes the entire application window to freeze

I tried the roundup function as well - with the same results.

Fowmy
Super User
Super User

@sam245gonsalves 

 

It should work, try the fully qualified column name

 

New Column = Ceiling(Table[num_ofDays]/30.5, 1)

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.