Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Convert data from one form to another

Dear All,

I have a report with status (as in values) which means it is in format of Action Status : Comp/ Pending/ Overdue, here, if number other than zero is present then that means the point has that many number of sub tasks (4/0/0 - means 4 subtasks in completed stage. How do I write dax code than using conditional formatting.

 

Simply: when there is a number other than zero in the format of Comp/ Pending/ Overdue, then that many sub tasks at its stage.

 

    1. first click on your column with the 3 statuses,
    2. then in the Transform ribbon click on the "Split Column" button
    3. then chose the "by Delimiter" option and choose "/" as your delimiter (Power Query should detect this)
    4. then click on ok, this should split your column into 3 numeric values
    5. rename the 3 new columns to "Comp", "Pend" and "Overdue"
    6. then click on the "Add Column" ribbon
    7. then click on "Custom Column"
    8. and paste in the following code 

     

    if [Comp] = 0 and [Pend]= 0 and [Overdue] = 0 then "No Actions Defined"
    else if [Comp] > 0 and [Pend] > 0 then "Partially Complete" 
    else if [Comp] > 0 then "Complete"
    else if [Pend] > 0 then "Pending"
    else if [Overdue] > 0 then "Overdue" 
    else "Other"

5 Replies

  • This looks like Power Query code, not DAX. The other option here would be to do a split transform using "/" to split the values in order to create 3 separate columns for each of Comp, Pending & Overdue. Then you could do numeric > 0 checks instead of having to type out. The only problem is that to check 2 columns as in the "Partial" case you would have to edit the expression code by hand as the Wizard page does not have a way to generate and "AND" condition

     

    = Table.AddColumn(#"Renamed Columns", "Custom", each 
    if ([Comp] > 0) and ([Pend] > 0) then "Partial"
    else if [Comp] > 0 then "Complete"
    else if [Pend] > 0 then "Pending"
    else "Overdue")
    • Anonymous's avatar
      Anonymous
      Not applicable

      Dear d_gosbell ,

       

      Can you please elaborate step by step, Because i am a learner to power BI

      • d_gosbell's avatar
        d_gosbell
        Icon for Super User rankSuper User
        1. first click on your column with the 3 statuses,
        2. then in the Transform ribbon click on the "Split Column" button
        3. then chose the "by Delimiter" option and choose "/" as your delimiter (Power Query should detect this)
        4. then click on ok, this should split your column into 3 numeric values
        5. rename the 3 new columns to "Comp", "Pend" and "Overdue"
        6. then click on the "Add Column" ribbon
        7. then click on "Custom Column"
        8. and paste in the following code 

         

        if [Comp] = 0 and [Pend]= 0 and [Overdue] = 0 then "No Actions Defined"
        else if [Comp] > 0 and [Pend] > 0 then "Partially Complete" 
        else if [Comp] > 0 then "Complete"
        else if [Pend] > 0 then "Pending"
        else if [Overdue] > 0 then "Overdue" 
        else "Other"