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
ed7
Employee
Employee

Calculated Column: net new over last day for each category

I have a table that has data similiar to the table below, I need to calculate net new for each date per category. For example second line would show net new of 33, fourth line net new is 3. I would prefer to use  a Calculated column not Measure. Tried different recommendation, nothing worked for Calculated Column (but some formulas worked to create Measure). How can I create a calc column for Net New?

CategoryDateRunning total from year start
A01/01/202012
A01/02/202045
B01/01/20202
B01/02/20205
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=if(ISBLANK(CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Category]=EARLIER(Data[Category])&&Data[Date]<EARLIER(Data[Date])))),BLANK(),Data[Running total from year start]-LOOKUPVALUE(Data[Running total from year start],Data[Date],CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Category]=EARLIER(Data[Category])&&Data[Date]<EARLIER(Data[Date]))),Data[Category],Data[Category]))

Hope this helps.

Untitled.png


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

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@ed7 

I believe EARLIER is best for you if you want a calculated column.

 

Column = 
var current_day  = CALCULATE(SUM('Table'[Runningtotal]),FILTER('Table','Table'[Date] = EARLIER('Table'[Date]) && 'Table'[Category]=EARLIER('Table'[Category])))

var previous_day = CALCULATE(SUM('Table'[Runningtotal]),FILTER('Table','Table'[Date] = EARLIER('Table'[Date])-1 &&'Table'[Category]=EARLIER('Table'[Category])))

Return current_day - previous_day

 

net new.JPG

 

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

Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=if(ISBLANK(CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Category]=EARLIER(Data[Category])&&Data[Date]<EARLIER(Data[Date])))),BLANK(),Data[Running total from year start]-LOOKUPVALUE(Data[Running total from year start],Data[Date],CALCULATE(MAX(Data[Date]),FILTER(Data,Data[Category]=EARLIER(Data[Category])&&Data[Date]<EARLIER(Data[Date]))),Data[Category],Data[Category]))

Hope this helps.

Untitled.png


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

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.