Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Sweetcapitan
Frequent Visitor

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!
1 ACCEPTED SOLUTION

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.

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Phil_Seamark
Employee
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)


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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!

 

chart.PNG

 

 

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.

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ah ha, I got it!  Thanks a lot @v-yulgu-msft!

 

Now I encounter another issue.  Since each test is conducted at different time, the length of response curve varies (chart 1).  When I plotted the curve with the help of your answer, I got chart 2 below - basically the curve drop to zero where there is no data at the response date (x axis).  How should I solve this?


Capture1.PNGCapture2.PNG

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.