Forum Discussion

DeanM's avatar
DeanM
Frequent Visitor
8 years ago
Solved

new column to enter data in a range

Hi,

New to BI and I am trying to create a new column for sale dates into 4 categories (0-30, 31-60, 61-90, 91+).  I have a column of sale days.

 

  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi

     

    Try this

    Bucket Range = SWITCH( TRUE(), 
        Table1[Value]<=30,"0-30",
        Table1[Value]<=60,"31-60",
        Table1[Value]<=90,"61-90","91+")


    Thanks
    Raj

     

8 Replies

  • PattemManohar's avatar
    PattemManohar
    Icon for Community Champion rankCommunity Champion

    Try using "Conditional Column" under Power Query Editor, where you can define your ranges using IF Clause.

    • vee_ngoru's avatar
      vee_ngoru
      New Member

      Tried this it didn't give me the correct bucket ranges.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Conditional column is the way to do in power Query, as suggested by PattemManohar.

     

    Alternatively, You can do this as calculated column in Power BI model as well. Go to Modelling Tab -> New column-> Write your DAX formula here. ( IF (<con1> , "0-30",<Con2>,"31-60" , etc)

     

    Thanks

    Raj

    • DeanM's avatar
      DeanM
      Frequent Visitor

      In Power BI I have a column sales days ranging from 0-500.  I need a formula for the new column sales profile 0-30, 31-60, 61-90, 90+.  Keep getting errors.

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        What formula you use? Show your sample data and formula you are trying.

         

        Thanks

        Raj