Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to change columns based on another column

Hi, I am trying to get from here: 

To here: 

 

In other words, I would like to use Code to adjust Name and Active, yet count should be just summed up. Any idea how to do it?

  • Anonymous 

    How to get the name? Do you want to get the name which active is "yes"?

    if so, you can try this.

    Table 2 = SUMMARIZE('Table','Table'[CODE],"COUNT",SUM('Table'[COUNT]),"NAME",MAXX(FILTER('Table','Table'[ACTIVE]="Yes"),'Table'[Name]),"Active","Yes")

     

3 Replies

  • Anonymous 

    How to get the name? Do you want to get the name which active is "yes"?

    if so, you can try this.

    Table 2 = SUMMARIZE('Table','Table'[CODE],"COUNT",SUM('Table'[COUNT]),"NAME",MAXX(FILTER('Table','Table'[ACTIVE]="Yes"),'Table'[Name]),"Active","Yes")

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    You could try to use ALLEXCEPT function to get the separate results.

    CALCULATE(COUNT(...), ALLEXCEPT(Table, Table[Name]))

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Could you tell me if your problem has been solved?
    If it is, kindly Accept it as the solution. More people will benefit from it.
    Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.


    Best Regards,
    Stephen Tao