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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
feralvarez994
Helper II
Helper II

Group with DAX

Hi everyone! I have an issue here,

i have a column in which i have transformed a number string in date (AT_FECREM_NEW)

feralvarez994_0-1649868840217.png

and then another column that makes the datediff between that day and today.

feralvarez994_1-1649868878757.png

 

The thing is that i want to group those results in 4 groups:

 - 0-30 days

 - 30-60 days

- 60-90 days

 - more than 90 days

I'm doing this in this way but im finding an error

feralvarez994_2-1649868930621.png

 

When i make the calculated column with if, it tells me that cant use Variant data type to define calculated columns, can someone help me? I tried using PQuery but in there there are not shown the columns that i create with DAX.

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @feralvarez994 

 

Maybe you can try to carry out one more step.

Column:

Group = 
IF([Dias]>90,1,IF([Dias]>60,2,IF([Dias]>30,3,IF([Dias]>0,4,0))))
Column = 
IF([Group]=1,">90",IF([Group]=2,"60-90",IF([Group]=3,"30-60",IF([Group]=4,"0-30","0"))))

vzhangti_1-1650283872909.png

Is this the output you expect?

 

Best Regards,

Community Support Team _Charlotte

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-zhangti
Community Support
Community Support

Hi, @feralvarez994 

 

Maybe you can try to carry out one more step.

Column:

Group = 
IF([Dias]>90,1,IF([Dias]>60,2,IF([Dias]>30,3,IF([Dias]>0,4,0))))
Column = 
IF([Group]=1,">90",IF([Group]=2,"60-90",IF([Group]=3,"30-60",IF([Group]=4,"0-30","0"))))

vzhangti_1-1650283872909.png

Is this the output you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

 

Hi! This works, thanks you a lot!

AilleryO
Memorable Member
Memorable Member

Hi,

 

Can you check the Data type of your calculated column [Dias C antiguidad] ?

It might not be a type numeric (whole number, or Decimal value or fixed decimal value).

To change type, select your column  in field panel, then go to Column Tools tab et choose a numric data type and choose your format as well.

 

Tell us if it works after changing the type ?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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