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

Grouping segments of days in a calculated column

Hi there

 

I'm trying to group segments of days of customer late payments in a new column based on the number of delinquent days in different groups, 1-29 days late, 30-59 days late, etc. 

 

I realize that DAX takes the first true condition when I use this IF ELSE formula since I'm only getting "1-29 days" for the entire column. I tried adding AND function to satisfy multiple conditions but I got an error "Token Else expected" 

 

Capture.PNG

 

 

 

I'm fairly new to working with Power BI so apologies if there's a better approach I should be doing

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1657010394246.png

Here are the steps you can follow:

1. Go to Power query and select add column – Custom column.

vyangliumsft_1-1657010394248.png

2. Enter the following information.

 

if [delinquent days] >=1 and [delinquent days]<=29
then "0-29 days"
else
if [delinquent days] >=30 and [delinquent days]<=59
then "30-59 days"
else
"GT 60"

 

vyangliumsft_2-1657010394252.png

3. Result:

vyangliumsft_3-1657010394254.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

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

View solution in original post

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1657010394246.png

Here are the steps you can follow:

1. Go to Power query and select add column – Custom column.

vyangliumsft_1-1657010394248.png

2. Enter the following information.

 

if [delinquent days] >=1 and [delinquent days]<=29
then "0-29 days"
else
if [delinquent days] >=30 and [delinquent days]<=59
then "30-59 days"
else
"GT 60"

 

vyangliumsft_2-1657010394252.png

3. Result:

vyangliumsft_3-1657010394254.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Anonymous .

Try like

 

if [delinquent days] >=1 and [delinquent days] <= 29 then "0-29"

else [delinquent days] >=30 and [delinquent days] <= 59 then "30-59"

else "GT 60"

Anonymous
Not applicable

@amitchandak thanks for your reply

 

I'm getting this expected comma error. Am I missing anything there? 

 

Capture.PNG

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.