Forum Discussion

sanjeev803's avatar
sanjeev803
Icon for Helper I rankHelper I
9 years ago
Solved

How to create time slots in Power BI data set ?

 Hi All,

My data looks like this in excel:

Networkdays                 CYCLE TIMES
3                                    0-3 days
1                                    0-3 days
51                                 31+ days
4                                   4-7 days
4                                  4-7 days
14                                8-14 days

For "Cycle Time" there is a formula in this column that is
=IF(A2<=3,"0-3 days",IF(A2<=7,"4-7 days",IF(A2<=14,"8-14 days",IF(A2<=30,"15-30 days","31+ days"))))

I want to do same in Power BI Desktop.
Please assist how we can build a column like Cycle Time in Power BI dataset.

Thank you.

  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi sanjeev803

    Right click your table in Power BI Desktop, select “New column”, paste the following formula. Then create a table visual, for more details, see the example in the screenshots below.

    CYCLE TIMES = IF(Table[Networkdays]<=3, "0-3 days",IF(Table[Networkdays]<=7,"4-7 days",IF(Table[Networkdays]<=14,"8-14 days",IF(Table[Networkdays]<=30, "15-30 days","31+ days"))))


    Thanks,
    Lydia Zhang

  • chbraun's avatar
    chbraun
    9 years ago

    ... and if you want to avoid all those nested IF statements you can use the SWITCH statement:

     

    SWITCH(TRUE(),

                  NetworkDays <= 3, "0-3 days",

                  NetworkDays <=10, "3-10 days",

                  "10+ days")

     

    Cheers,

     

    Christian

     

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi sanjeev803

    Right click your table in Power BI Desktop, select “New column”, paste the following formula. Then create a table visual, for more details, see the example in the screenshots below.

    CYCLE TIMES = IF(Table[Networkdays]<=3, "0-3 days",IF(Table[Networkdays]<=7,"4-7 days",IF(Table[Networkdays]<=14,"8-14 days",IF(Table[Networkdays]<=30, "15-30 days","31+ days"))))


    Thanks,
    Lydia Zhang

    • chbraun's avatar
      chbraun
      Icon for Helper I rankHelper I

      ... and if you want to avoid all those nested IF statements you can use the SWITCH statement:

       

      SWITCH(TRUE(),

                    NetworkDays <= 3, "0-3 days",

                    NetworkDays <=10, "3-10 days",

                    "10+ days")

       

      Cheers,

       

      Christian

       

  • Hi All,

    My data looks like this in excel:

    Networkdays        CYCLE TIMES
    3                           0-3 days
    1                           0-3 days
    51                        31+ days
    4                          4-7 days
    4                         4-7 days
    14                       8-14 days

    For "Cycle Time" there is a formula in this column that is
    =IF(A2<=3,"0-3 days",IF(A2<=7,"4-7 days",IF(A2<=14,"8-14 days",IF(A2<=30,"15-30 days","31+ days"))))

    I want to do same in Power BI Desktop.
    Please assist how we can build a column like Cycle Time in Power BI dataset.

    Thank you.