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
menerso
Regular Visitor

Percent change from previous date

I am trying to create a report in PowerBI that shows the Percentage Change of Crictical data from the previous dates.  The dates are not be consistant for amount of days between each date.

 

I have a report that looks similar to the table below, but I can't seem to pull up the Critical Previous data so that I can create my Percent Change column/measure.  I was able to create a Previous Date calculated column in my testing... but it didn't help me.

 

I think I have tried every example of what people have put out there, but I either get nothing showing or an error.

 

AgencyDateCriticalPrevious DateCritical PreviousPercent Change
Agency19/16/2244   
Agency110/6/22229/16/2244-50%
Agency110/16/221010/6/2222-55%
Agency New29/16/22100   
Agency New210/6/22759/16/22100-25%
Agency New210/16/222510/6/2275-67%

 

Agency is pulled from another table called Agency Hosts.  It connects to a host field which is not in this report.
Critical is a calculated column
Critical Previous may not be needed, I was just happy I could figure that one out.
 
Ultimately, I am looking for the Percent Change, but I figure I need the Critical Previous column to get that.

 

8 REPLIES 8
menerso
Regular Visitor

With the data I gave, this worked great.  But went I put it into my actual PowerBI, I end up getting a circular error.  I am assuming it is because of the "Risk Critical" field (which represented the "Critical" field in out test files) is filtering out Critical data in the column.  I have other fields like "Risk High" and "Risk Low" that filters out those in a column.

 

This is what the Risk Critical field looks like.  

 

Risk Critical = IF(ISBLANK(CALCULATE(Countrows('Vulnerabilities'),'Vulnerabilities'[OMC Risk]="Critical")),0,CALCULATE(Countrows('Vulnerabilities'),'Vulnerabilities'[OMC Risk]="Critical"))
 
circular error.jpg
 
So, I am stuck on how to use this Risk Critical field in this equation.
 
Thanks,
Marty
v-xiaosun-msft
Community Support
Community Support

Hi @menerso ,

 

Has your problem be solved?

If so, please mark the answers you need as a solution to help the other members find it more quickly.

If not, please tell us in order that we can help you futher more.

 

Best Regards,
Community Support Team _ xiaosun

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@menerso 

is this what you want?

Column = 
var _last=maxx(FILTER('Table','Table'[Agency]=EARLIER('Table'[Agency])&&'Table'[Date]<EARLIER('Table'[Date])),'Table'[Date])
var _lvalue=maxx(FILTER('Table','Table'[Agency]=EARLIER('Table'[Agency])&&'Table'[Date]=_last),'Table'[Critical])
return if(ISBLANK(_last),blank(),DIVIDE('Table'[Critical]-_lvalue,_lvalue))

1.PNG





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

Proud to be a Super User!




Thanks for your response.  That did not work.  It does work if all fields are in one table, but I have the Agency in a different table.

Just so you know, 

Agency column is in a related table which is indexed off of another field.  I am unable to add the 'table'[Agency] field after the EARLIER command.  It just doesn't show up as an option.

 

The Critical column is a measure.

I tested yours with a related table and I got this...
Screenshot 2022-11-02 164115.png

@menerso 

if you want to create a measure, you can try this

Measure = 
var _last=maxx(FILTER(all('Table'),'Table'[Agency]=max('Table'[Agency])&&'Table'[Date]<max('Table'[Date])),'Table'[Date])
VAR _lvalue=maxx(FILTER(all('Table'),'Table'[Agency]=max('Table'[Agency])&&'Table'[Date]=_last),'Table'[Critical])
return if(ISBLANK(_last),blank(),DIVIDE(max('Table'[Critical])-_lvalue,_lvalue))

pls see the attachment below





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

Proud to be a Super User!




@ryan_mayu  Thanks again for the reply. 

I mentioned that your code DOES work for a single flat table, but does not work when I have two tables that are related.  The file you sent was of a single table.
Do you know how to make this work with two related tables.  I included the test file I have been using here  -  Marty Test.pbix 
Screenshot 2022-11-03 100240.pngScreenshot 2022-11-03 100150.png

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@menerso 

pls see the attachment below

 





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

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.