Forum Discussion

Babu34's avatar
Babu34
New Member
1 year ago
Solved

undefined

Hi

I want to display number of requests on monthly basis by year and by service type( I have two service types) 

In simpler terms

x axis - Month

y axis - Measure

legend - Year and Service type

 

how to achieve this requirement. If any visual didn't support this type of formatting please suggest me the alternate way to do this

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Babu34,

     

    Power BI doesn’t let you use two separate legends (like one for Year and one for Service Type) in the same chart.

    But you can work around this by combining both into one as suggested by Royel . Just create a new column that joins Year and Service Type together, like this:

    YearService = FORMAT([RequestDate], "YYYY") & " - " & [ServiceType]

    This way, your legend will show values like "2023 - Type A" or "2024 - Type B", and you can compare them easily in one chart.

     

    Thanks & Regards,

    Prasanna Kumar

  • Royel's avatar
    Royel
    1 year ago

    Babu34 Lets try something new, We can create a "Dynamic Legend with Parameter" and use it in the visual. 

    Steps: 

    1. Go to Modeling tab → New parameter → Fields

    2. Add both "Year" and "ServiceType" fields to the parameter

    3. Ceates a slicer that allows users to switch between viewing by Year or by Service Type
    4. Now create a line or Clustered Column Chart where legend item is the new parameter. 
    Let me know how it goes. 

     

9 Replies

  • You can use a line chart or a bar chart, it will work

     

    If this helped, please consider giving kudos and mark as a solution

    me in replies or I'll lose your thread

    consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI

  • I m already using a clustered column chart where I m showing month on X axis and Number of requests on Y axis and Year as legend. Now i want it to be stacked by both year and service type which means i have to add one more field into legend group which is not achieveable to me. Please give me your inputs on this

  • Royel's avatar
    Royel
    Super User

    Hi Babu34 , you can achieve this by choosing a Clustered Column Chart

    Steps:

    1. Create a calculated column: Year_ServiceType = [Year] & " " & [ServiceType]
    2. Drag Month to X-axis
    3. Drag Request Count to Values
    4. Drag the new Year_ServiceType field to Legend

    This will give you clustered bars for each month, with different colors representing each year-service combination.


    If you find this helpful please mark my post as the solution, it helps others with the same challenge find the answer!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Babu34,

     

    Thank you for reaching out to the Microsoft Fabric Forum Community, and special thanks to Royel  and FBergamaschi  for their prompt and helpful responses.

     

    Just following up to see if the solutions provided by community members were helpful in addressing the issue.

    If one of the responses helped resolve your query, please consider marking it as the Accepted Solution. Feel free to reach out if you need any further clarification or assistance.

     

    Best regards,
    Prasanna Kumar

    • Babu34's avatar
      Babu34
      New Member

      I didnt find any solution as helpful as of now. My goal is to achieve the comparison across two legends. If i cant achieve it please suggest me any alternative solution for that

      • Royel's avatar
        Royel
        Super User

        Babu34 Lets try something new, We can create a "Dynamic Legend with Parameter" and use it in the visual. 

        Steps: 

        1. Go to Modeling tab → New parameter → Fields

        2. Add both "Year" and "ServiceType" fields to the parameter

        3. Ceates a slicer that allows users to switch between viewing by Year or by Service Type
        4. Now create a line or Clustered Column Chart where legend item is the new parameter. 
        Let me know how it goes. 

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Babu34,

     

    Power BI doesn’t let you use two separate legends (like one for Year and one for Service Type) in the same chart.

    But you can work around this by combining both into one as suggested by Royel . Just create a new column that joins Year and Service Type together, like this:

    YearService = FORMAT([RequestDate], "YYYY") & " - " & [ServiceType]

    This way, your legend will show values like "2023 - Type A" or "2024 - Type B", and you can compare them easily in one chart.

     

    Thanks & Regards,

    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Babu34,

     

    Just following up to see if the solutions provided by community members were helpful in addressing the issue.

    If one of the responses helped resolve your query, please consider marking the perticular response as the Accepted Solution. Feel free to reach out if you need any further clarification or assistance.

     

    Best regards,
    Prasanna Kumar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Babu34,

     

    Just following up to see if the responses provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.

     

    Best regards,

    Prasanna Kumar