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

Insert a new row in PowerBI Table based on calculation

I have a series of data and need to generate forecast based on the max date and slope for next 1 year using the formula y=mx+b. After the current date it has to insert a new row in the table based on the formula calculation. Can someone help me how to do it or run loops in power bi.

ArunaM_0-1597102665297.png

and the expected output was like this

Account_NameAPP_FULL_NAMEMAX_DATEINDEX
Deva8/11/20202
Deva8/12/20203
Deva8/11/2021365
6 REPLIES 6
v-lili6-msft
Community Support
Community Support

hi  @ArunaM 

For your case, you could use DAX to create a new table

or create measure and show it in the table viusal.

What is your logic of your expected output(y=mx+b)? 

 

Please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Lin

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

If you really don't need the rows actually added to the model, you could do this with DAX (i.e., calculate future values based on past values).  You can first try to use the Analytics pane of the visual to add forecasting.  If that meets your need, great.

 

If not, it is silly, but it is much harder than it needs to be to calculate slope and intercept with DAX. 

Please see this post - https://xxlbi.com/blog/simple-linear-regression-in-dax/

 

To do it w/o adding actuals rows you would have a Date table that contains your future dates, make a measure that makes a virtual table of your "past" values (x and y), calculate slope and intercept for those values, find the # of days in the future your "current" date is (i.e., your new X value) and plug it into the y=mx+b calculation to plot your result.  It's doable but harder than it should be.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


How can I create future dates based on current or previous date, this is where I got stuck.

hi @ArunaM 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

 

Regards,

Lin

 

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

You cannot do that with Power BI tables.  You either will have to use (non-persistent) table variables, or you need to move this request to Power Query.

How can i do it in Power Query? Thanks!

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.

Top Solution Authors