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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ManuSankaran
New Member

Converting Month into numbers and use it for dividing a formula (per month data)

hi, i need to know how to convert month (which is picked from a data source in SAP) into numbers and use it for dividing a total value. -- finding average per month

For example, the total activities for January is 10, February is 20. If i want to add these 2 values and get an average of January and February -- how do write the formula?

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Assuming you also have a year column, you should first create a Date column (assume the day to be 1).  Thereafter create a Calendar Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name column by Month number.  Create a relationship (many to One and Single) from the Date column of the Data Table to the Date column of the Calendar Table.  From the Calendar Table, drag Year and Month name.  Select 1 year and 1 month.  Write these measures:

Total = sum(Data[Sales])

YTD average = averagex(filter(values(Calendar[month name]),datesbetween(calendar[date],date(year(min(calendar[date])),1,1),max(calendar[date]))),[Total])

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Arul
Super User
Super User

@ManuSankaran ,

First you need to have separate dimesion date table to count the dates and then try the below formula,

Average = 
VAR _countOfActivitives = COUNT('Table'[Activities])
VAR _noOfDays = COUNTROWS(ALLSELECTED('Calendar'))
VAR _result = _countOfActivitives/_noOfDays
RETURN _result

Thanks,

Arul





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

Proud to be a Super User!


LinkedIn


Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors