Forum Discussion

Sweetcapitan's avatar
Sweetcapitan
Frequent Visitor
8 years ago
Solved

Plotting Curves by Group

Hi all,
I am puzzled with a task that is easy to do in excel but I don’t know how to do it in power BI and need your help. Basically I have 3 fields X, Y, Z in a table and I want to plot Y against X group by Z. Say there are 5 distinct values of Z, then thd resulting visual would have 5 curves of Y against X. The visual will also reflect all slicers placed on the same tab. Any tips? Thanks!
  • v-yulgu-msft's avatar
    v-yulgu-msft
    8 years ago

    Hi Sweetcapitan,

     

    Please create a measure like below:

    Running total =
    CALCULATE (
        SUM ( 'Plotting Curves'[Y] ),
        FILTER (
            ALLEXCEPT ( 'Plotting Curves', 'Plotting Curves'[Z] ),
            'Plotting Curves'[X] <= MAX ( 'Plotting Curves'[X] )
        )
    )

    Then, add corresponding fields and above measure into a line chart.

     

    Best regards,

    Yuliana Gu

4 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Icon for Microsoft Employee rankMicrosoft Employee

    Sure, any chance of some sample data + a screenshot showing how it would look if you used Excel.  This will make it easier build (plus help clarify any questions)

    • Sweetcapitan's avatar
      Sweetcapitan
      Frequent Visitor

      Thanks Phil!

       

      Here is the data. 

      Y is the response so the outcomes are Y (1) or N (0). 

      X is time of response. 

      Z is the test group. The data here shows 2 groups - A and B.

       

      timerespgroup
      XYZ
      11A
      20A
      21A
      20A
      21A
      20A
      31A
      30A
      31A
      30A
      31A
      30A
      31A
      30A
      11B
      10B
      11B
      10B
      21B
      20B
      21B
      21B
      21B
      21B
      31B
      31B
      31B
      31B
      31B
      31B
      31B

       

      in Excel I would create a pivot table to summarize the results to get two series (A and B) of responses against time (table 1).  Then I would cumulate it as table 2 and feed it to create the final chart, which is the visual I would like to create in Power BI.  Thanks!

       

       

       

      • v-yulgu-msft's avatar
        v-yulgu-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi Sweetcapitan,

         

        Please create a measure like below:

        Running total =
        CALCULATE (
            SUM ( 'Plotting Curves'[Y] ),
            FILTER (
                ALLEXCEPT ( 'Plotting Curves', 'Plotting Curves'[Z] ),
                'Plotting Curves'[X] <= MAX ( 'Plotting Curves'[X] )
            )
        )

        Then, add corresponding fields and above measure into a line chart.

         

        Best regards,

        Yuliana Gu