Forum Discussion

Gasdetect40's avatar
Gasdetect40
Frequent Visitor
1 year ago
Solved

Combining 2 Companies from Same Column

Good Day!   I'm have a stacked bar chart visual with a list of companies and company locations in a table with Techs and Laborer's for each. (see below) I would like to write a measure that combine...
  • elitesmitpatel's avatar
    1 year ago

    Hi Gasdetect40 
    you can create a new column 

    dax formula ->

    Company Group = SWITCH(TRUE(),
    Company_Labor_Tech_Data[Company] = "PMOL", "PMOL",
    Company_Labor_Tech_Data[Company] =  "Shelby's Mustard", "PMOL",
    Company_Labor_Tech_Data[Company] = "Ed Frank", "Ed Frank")



    and use stacked bar chart  to get this output


    If it helps please give Kudos and Accept it as solution , which will help other members in future



  • v-sshirivolu's avatar
    1 year ago

    Hi Gasdetect40 ,

    Thanks for reaching out to the Microsoft fabric community forum.

    Create a Merged Company Column

    Merged Company =
    SWITCH(
    TRUE(),
    'Table'[Company] IN {"PMOL", "Shelby's Mustard"}, "PMOL",
    'Table'[Company]
    )

     

    Unpivot the Techs and Laborer Columns

    In the query editor:

    Select the columns “# of Techs” and “# of Laborer”.
    Right-click one of them and choose “Unpivot Columns”.
    Click “Close & Apply” to return to the main Power BI interface.


    Create the Stacked Bar Chart

    Set the following fields:
    X-axis : Value
    Y-axis : Merged Company
    Legend : Attribute


    Please find the below attached .pbix file for your reference.

    If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

    Best Regards,
    Sreeteja.
    Community Support Team