Forum Discussion

TusharGaurav's avatar
TusharGaurav
Icon for Helper III rankHelper III
1 year ago
Solved

How to show multiple lines based on the slicer values selected when there are 2 different slicers.

Hi Experts,

 

In my report I am showing a line chart having revenue trend with respect to Date.

There are two slicers i.e. for Country and Product Group.

If nothing is selected, there will be only one line however if any Product Group is selected the the line chart should display multiple line Corresponding to the Countries which belong to the Product Group selected.

e.g. If Product Group "Clothing Line" is selected which have "India" and "USA", then in the line chart two different line should be displayed.

Can you please let me know how we achieve this scenario in PowerBI.

 

 

Thanks and Regards,

Tushar Gaurav

 

  • Hi TusharGaurav 

    Can you please try the below DAX.


    DynamicRevenue =
    VAR IsProductGroupSelected =
        ISFILTERED('Table'[ProductGroup])
    RETURN
    IF(
        IsProductGroupSelected,
        SUM('Table'[Revenue]),
        CALCULATE(
            SUM('Table'[Revenue]),
            REMOVEFILTERS('Table'[Country])  
        )
    )


    x-axis --- Date
    y-axis---- DynamicRevenue
    legend--- Country
     
     
    before selecting

     

    After selecting

     

     
    If this answers your question, kindly accept it as solution and give kudos.

7 Replies

  • Hi TusharGaurav 

    Can you please try the below DAX.


    DynamicRevenue =
    VAR IsProductGroupSelected =
        ISFILTERED('Table'[ProductGroup])
    RETURN
    IF(
        IsProductGroupSelected,
        SUM('Table'[Revenue]),
        CALCULATE(
            SUM('Table'[Revenue]),
            REMOVEFILTERS('Table'[Country])  
        )
    )


    x-axis --- Date
    y-axis---- DynamicRevenue
    legend--- Country
     
     
    before selecting

     

    After selecting

     

     
    If this answers your question, kindly accept it as solution and give kudos.
    • TusharGaurav's avatar
      TusharGaurav
      Icon for Helper III rankHelper III

      Hi mdaatifraza5556 

       

      Thanks for your response.

      But this dax is not working.

      Actually my requrirement is to display multiple lines corresponding to countries belonging to the Product group selected.

      e.g. If Product Group "Clothing Line" is selected which have "India" and "USA", then in the line chart two different line should be displayed.

      When I use the dax measure, the line chart is still showing a single line.

      Can you please help.

       

      Thanks and Regards,

      Tushar Gaurav

      • mdaatifraza5556's avatar
        mdaatifraza5556
        Icon for Super User rankSuper User

        Hi TusharGaurav 

        As you can see the above I have shared the snapshot of the output.

        You can see the first image if not selected the productgroup then it shows
        a single line which shows overall.

        And when productgroup is selected then the two line chart is displayed

         

         

    • TusharGaurav's avatar
      TusharGaurav
      Icon for Helper III rankHelper III

      Thanks a lot for help.

      l have one doubt, ie suppose l dont select any country, the in the chart's legend there will be legend of more than 100 countries and the line in the line chart is also multicoloured.

      ls it possible to have "all"as legend in place of multiple country legend.

      your response is really important.

       

      Thanks and Regards,

      Tushar Gaurav 

  • v-achippa's avatar
    v-achippa
    Icon for Community Support rankCommunity Support

    Hi TusharGaurav,

     

    Thank you for reaching out to Microsoft Fabric Community.

     

    Thank you mdaatifraza5556 for the prompt response.

     

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the super user resolved your issue?
    If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

     

    Thanks and regards,

    Anjan Kumar Chippa