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
UK_User123456
Resolver I
Resolver I

combining data into categories

Hi All,

 

Is there a way of being able to categorise my data into certain months for example, I have data that I want to be able to categorise into 0-12 months and 25-48 months and anything else would be "Other", what would be the quickest way of doing this?

 

Current Date30/09/2019
  
DateCategory
01/12/2002Other
01/09/20190-24
22/05/201825-48
13/07/2005Other
01/12/20180-24
01/01/20190-24
01/04/20190-24
05/05/201825-48
1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@UK_User123456  Please add a new column as below

 

Category = 
VAR _MonthsDiff = DATEDIFF([Date],TODAY(),MONTH)
RETURN IF(_MonthsDiff<=24,"0 -24",IF(_MonthsDiff<=48,"25 - 48","Other"))

Added MonthsDiff column, just for reference.

 

image.png





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

Proud to be a PBI Community Champion




View solution in original post

4 REPLIES 4
v-eachen-msft
Community Support
Community Support

Hi @UK_User123456 ,

 

You can also use M query to do it. Here is my test file, you could download and refer to it.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Hi,

 

I cannot see how you have created the workings as it wont let me update power bi? Are you able to post the working?

 

Thank you.

Hi @UK_User123456 ,

 

You could open query editor and find "APPLIED STEPS" in the right part. It shows each step to get the final result.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
PattemManohar
Community Champion
Community Champion

@UK_User123456  Please add a new column as below

 

Category = 
VAR _MonthsDiff = DATEDIFF([Date],TODAY(),MONTH)
RETURN IF(_MonthsDiff<=24,"0 -24",IF(_MonthsDiff<=48,"25 - 48","Other"))

Added MonthsDiff column, just for reference.

 

image.png





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

Proud to be a PBI Community Champion




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.