Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
en_90
Frequent Visitor

New/Removed Rows Day-Over-Day

Hello, 
 
I would like to identify and count the changes in sales orders day-over-day i.e. identify/count the number of sales orders that were added and removed day-over-day so ideally, when the data is refreshed, I am comparing and summarizing the orders that were added and removed from the previous day to the current day. 
 

For example, based on the below table, RUN_DATE = 10/29, SALES_ORDER = 0205902208-000100 should be categorized as NEW because it's present for 10/29 but not for 10/28. 

 

RUN_DATE = 10/29, SALES_ORDER = 0204644520-000100 should be unchanged, or categorized as "NO CHANGE" because it was present in both 10/28 and 10/29. 

 

RUN_DATE = 10/28, SALES_ORDER = 0208188033-000200 should have been categorized as NEW when the data was ran on 10/28 but the categoriziation should be updated to REMOVED , when the data is refreshed on 10/29, because it is no longer present in 10/29. 

 

The below table is just an example of the logic described above and my current data set only has the RUN_DATE and SALES_ORDER columns. The output does not have to match the below table 

 

I am hoping to be able to accomplish this through DAX. 

 

Any help is appreciated! 

 

en_90_0-1730222583814.png

 

3 REPLIES 3
v-xingshen-msft
Community Support
Community Support

Hi ALL,
Firstly  GilbertQ thank you for your solution!
And @en_90 ,According to your needs, we use countrows to determine whether the previous date exists in the latest date, if it exists NO Change If it does not exist, then it is New , I hope that my thinking for you!

NO or Change = 
VAR PreviousDate2 = 
CALCULATE(MAX('Table'[RUN_DATE]), 
    FILTER(ALL('Table'), 'Table'[RUN_DATE] < MAX('Table'[RUN_DATE]))
)
RETURN
IF(
    CALCULATE(
        COUNTROWS('Table'),
        'Table'[SALES_ORDER]=MAX('Table'[SALES_ORDER]),
        'Table'[RUN_DATE]=PreviousDate2)>0,
        "NO CHANGE",
        "NEW")
Remove = 
VAR CurrentDate =CALCULATE(MAX( 'Table'[RUN_DATE]),ALL('Table'))

RETURN 
IF(CALCULATE(
    COUNTROWS('Table'),
    'Table'[SALES_ORDER]=MAX('Table'[SALES_ORDER]),
    'Table'[RUN_DATE]=CurrentDate)>0,BLANK(),
    "REMOVE")

vxingshenmsft_0-1730362412542.png

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

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

 

 

@v-xingshen-msft thanks for the quick response. I have succesfully implemented your code but I need to be able to count the number of sales ordres that are new, no change and removed by RUN_DATE. WIth this code, I am unable to accomplish this. Any suggestions? Thank you. 

GilbertQ
Super User
Super User

Hi @en_90 

 

The pattern you are looking for is new and existing customers. Here is an article from Sql BI, which will explain the concept to you with DAX examples New and returning customers – DAX Patterns





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

Proud to be a Super User!







Power BI Blog

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.