Forum Discussion

feralvarez994's avatar
feralvarez994
Icon for Helper II rankHelper II
4 years ago
Solved

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)

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

 

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

 

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.

 

  • 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"))))

    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.

     

     

3 Replies

  • AilleryO's avatar
    AilleryO
    Icon for Memorable Member rankMemorable 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 ?

  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity 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"))))

    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.