-1

I have two columns of data like this: enter image description here

Now I want to turn tenure into buckets like this: enter image description here

I've searched but none of those works in Power bi. What should I do?

Ghost
  • 49
  • 6

1 Answers1

1

There is a very simple way to create groups and buckets. Simply right-click the field you want to group in the right bar and select "New group".

However, I find it quite finicky to use with fixed sized bins.

My preferred way it to simply create a new calculated column, using the SWITCH dax function:

tenure_group = 
VAR Val = Table[tenure]
RETURN
SWITCH(
    TRUE(),
    Val <= 5,
    "0-5 months",
    Val > 5 || Val <= 45,
    "6-45 months",
    Val > 45 || <= 69, 
    "46-69 months",
    "70+ months"
)
Jérémie L
  • 321
  • 3
  • 11
  • The syntax for 'Table' is incorrect. (DAX(VAR Val = Table[tenure]RETURNSWITCH( TRUE(), Val <= 5, "0-5 months", Val > 5 || Val <= 45, "6-45 months", Val > 45 || <= 69, "46-69 months", "70+ months"))). – Ghost Jun 30 '22 at 12:17
  • Yes, *table* is a reserved word. It should be in quotes. I've put it more as a placeholder. May I suggest to avoid naming a table "Table". – Jérémie L Jun 30 '22 at 12:29
  • I changed the code so it's now VAR Val = table1['CCA'[tenure]] and now it gives me this error: The end of the input was reached. – Ghost Jun 30 '22 at 12:34
  • If your table name is "CCA" and column name is "tenure". Then the syntaxt for the var is `VAR Val = CCA[tenure]` – Jérémie L Jun 30 '22 at 12:52
  • I fixed it and now it gives this error: A single value for column 'tenure' in table 'CCA' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, – Ghost Jun 30 '22 at 12:54
  • The formula I've provided is for a new **calculated column**. It doesn't work for a measure and would typically return this error. – Jérémie L Jun 30 '22 at 12:58