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
sv12
Helper III
Helper III

DAX Help

Hi,

I am trying to replicate the below Excel Calculation in Power BI: (Calculated Column)

 

Formula:

AD Line = AD Line (previous value) + Net Advances (Current Value)

For the 1st row, AD Line = Net Advances

 

Sample Data:

DateAdvancesDeclinesNet AdvancesAD Line
1/1/201914561549-93-93
1/2/20195712470-1899 
1/3/201913281684-356 

 

I appreceate any help!

 

Thanks

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @sv12 ,

Recursive calculated columns are a nightmare to be honest, but I got around it in your example. Your AD line is basically the SUM of all net advances of every row before the current row, plus the net advances of the current row. So, your AD Line will be calculated using the following calculated column:

AD Line2 = 
VAR curDate = Table2[Date]
RETURN
CALCULATE(SUM(Table2[Net Advances]), FILTER(ALL(Table2), Table2[Date] <= curDate))

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Kudo's are welcome 🙂





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

Proud to be a Super User!




View solution in original post

5 REPLIES 5
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @sv12 ,

Recursive calculated columns are a nightmare to be honest, but I got around it in your example. Your AD line is basically the SUM of all net advances of every row before the current row, plus the net advances of the current row. So, your AD Line will be calculated using the following calculated column:

AD Line2 = 
VAR curDate = Table2[Date]
RETURN
CALCULATE(SUM(Table2[Net Advances]), FILTER(ALL(Table2), Table2[Date] <= curDate))

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Kudo's are welcome 🙂





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

Proud to be a Super User!




@JarroVGIT  Thank you so much! That worked 🙂

nlefalher
Frequent Visitor

Hello SV12,

 

Your current value is today or a particulair day?

Also if you need previous value, what is the value expected ?

 

Could you give an exemple please?

 

BR

Hi @nlefalher ,

 

Thanks for your response.

 

Current value is the current row for the calculation of column AD Line.

 

Previous value is the value of the previous row in the same column (AD Line)

 

Example: https://school.stockcharts.com/doku.php?id=market_indicators:ad_line

 

Thanks

@sv12 ,

 

I am not an expert but I would say something like :

 

CALCULATE(
    SUM(Sales[AD])
    , 'Calendar'[Date] = today()-1
)   

 

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.