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
vitornmind
Frequent Visitor

How to create a protiftability line chart in %?

Sorry if this is a dumb question, but I've been studying Power BI and I am quite lost. I would like to build a profitability line chart, where my X axis is a date, my Y axis (values) is a percentage of increase, and my legend is a name. I will use an example of stock prices:

 

Id Name Date Value

1ABC22/07/201910.37
2F122/07/20191.99
3ABC23/07/201910.42
4F123/07/20192.07

 

If I plot the table above, the value of stock ABC is much higher than F1, so the lines will not be easily comparable. It is usual, in such scenario, to plot the profitability in % of these stocks.

 

image.png

 

How do I achieve this? Thanks in advance

1 ACCEPTED SOLUTION
richbenmintz
Solution Sage
Solution Sage

Hi @vitornmind 

 

Assuming that your data looks like your sample the following formula should work.

 

Change from Prior = divide(sum('Table1'[Value]), 
CALCULATE(sum(Table1[Value]), 
-- remove Data filter context on x axis
FILTER(ALL(Table1[Date]), 
-- get record for prior date
'Table1'[Date] = DATEADD(VALUES(Table1[Date]), -1, DAY))), 
--set divide by zero value to 1 to ensure that the -1 one part of the equation does not return -100% when denom is 0
1)-1

I hope this helps,

 

Richard



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


View solution in original post

1 REPLY 1
richbenmintz
Solution Sage
Solution Sage

Hi @vitornmind 

 

Assuming that your data looks like your sample the following formula should work.

 

Change from Prior = divide(sum('Table1'[Value]), 
CALCULATE(sum(Table1[Value]), 
-- remove Data filter context on x axis
FILTER(ALL(Table1[Date]), 
-- get record for prior date
'Table1'[Date] = DATEADD(VALUES(Table1[Date]), -1, DAY))), 
--set divide by zero value to 1 to ensure that the -1 one part of the equation does not return -100% when denom is 0
1)-1

I hope this helps,

 

Richard



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


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.