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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Tob_P
Helper V
Helper V

Filtering Sales with Dates

I have the following Measure which works well based on my model..

 

Total Sales (Stands) =
CALCULATE([Total Sales],  
USERELATIONSHIP('NAV_Sales History MASTER'[Posting Date], 'NAV_Item Ledger Entry'[Posting Date]),
TREATAS(VALUES('NAV_Stand Items'[Item No_]), 'NAV_Sales History MASTER'[Item No])
)+0
 
Can anyone suggest an amendment to it so that it will only include Sales when the Posting Date in 'NAV_Sales History MASTER, is greater than or equal to the Posting Date in 'Nav_Iten Ledger Entry?
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Tob_P 
It was a bit confusing as TP2 Posting date is 12/06/2020 which is before the very first date in the sample sales table. See below screenshot. However, I believe the proposed solution is workable but I have serious doubts about the performance. Please refer to attached sample file amended with the solution.

1.png2.png

Total Sales On and After = 
SUMX (
    GENERATE ( 
        'Nav_Item Ledger Entry',
        CALCULATETABLE ( VALUES ( 'Nav_Stand Items'[Item No_] ) )
    ),
    VAR PostingDate = 'Nav_Item Ledger Entry'[Posting Date]
    VAR CurrentItem = 'Nav_Stand Items'[Item No_]
    VAR CurrentCustomerSales = CALCULATETABLE ( 'Nav_Sales History Master' )
    VAR FilteredSalesTable = 
        FILTER ( 
            CurrentCustomerSales,
            'Nav_Sales History Master'[Item No] = CurrentItem
                && 'Nav_Sales History Master'[Posting Date] >= PostingDate
        )
    RETURN
        SUMX ( FilteredSalesTable, 'Nav_Sales History Master'[Sales] )
)

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Tob_P 
It was a bit confusing as TP2 Posting date is 12/06/2020 which is before the very first date in the sample sales table. See below screenshot. However, I believe the proposed solution is workable but I have serious doubts about the performance. Please refer to attached sample file amended with the solution.

1.png2.png

Total Sales On and After = 
SUMX (
    GENERATE ( 
        'Nav_Item Ledger Entry',
        CALCULATETABLE ( VALUES ( 'Nav_Stand Items'[Item No_] ) )
    ),
    VAR PostingDate = 'Nav_Item Ledger Entry'[Posting Date]
    VAR CurrentItem = 'Nav_Stand Items'[Item No_]
    VAR CurrentCustomerSales = CALCULATETABLE ( 'Nav_Sales History Master' )
    VAR FilteredSalesTable = 
        FILTER ( 
            CurrentCustomerSales,
            'Nav_Sales History Master'[Item No] = CurrentItem
                && 'Nav_Sales History Master'[Posting Date] >= PostingDate
        )
    RETURN
        SUMX ( FilteredSalesTable, 'Nav_Sales History Master'[Sales] )
)

Hi @tamerj1 

 

Thank you for taking the time to look at this one, sorry for delay in coming back to you too. Works a treat so thank you, but yes, you are absolutely right about perfomance. It's very resource heavy!

Tob_P
Helper V
Helper V

@tamerj1 

 

Here is link to a sample version of the report for anyone who would like to offer any guidance

tamerj1
Super User
Super User

Hi @Tob_P 

how does your report look like? What columns are involved in you visual?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.