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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nesselman
Helper I
Helper I

Calculating a SUM if Date is Less Table Date

What I'm trying to do is SUM all the Inventory if the CategoryEnding Date is <= the Weekending Date.

 

TABLE1 is a simple calendar

TABLE2 is a table with Ending Date and Inventory

NO Relationships (because that ties the dates together)

 

= CALCULATE(SUM([Inventory]),[CategoryEnding]<='TABLE1'[Weekending])

This gives "expecting a true/false

 

How can I write this DAX measure please?

 

TABLE1 TABLE2     
Weekending CategoryEndingInventory   
10/14/2022 10/28/2022$1,000    
10/21/2022 11/11/2022$5,000    
10/28/2022 11/18/2022$500    
11/4/2022 12/2/2022$7,500    
11/11/2022       
11/18/2022       
11/25/2022       
12/2/2022       
        
        
PBI Table       
WeekEndingTotal to CategoryEnding Notes    
10/14/2022$14,000 Since all Dates are > Weekending Date they SUM
10/21/2022$14,000      
10/28/2022$14,000      
11/4/2022$13,000 lose the 10/28 Category Ending 
11/11/2022$13,000      
11/18/2022$8,000 lose the 11/11 Category Ending 
11/25/2022$7,500 lose the 11/18 Category Ending 
12/2/2022$7,500      
12/9/2022$0 lose the 12/2 Category Ending  
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@nesselman , if they are not related you can work on selected value or min or max

 

example

 

CALCULATE(SUM(Table2[Inventory]),filter(Table2, table2[CategoryEnding]<=max('TABLE1'[Weekending]) ))

View solution in original post

3 REPLIES 3
Thennarasu_R
Responsive Resident
Responsive Resident

Measure= var A=CALCULATE(SUM([Inventory]),userelationship(CategoryEnding Date ,Weekending Date)
               Var Result=calculate(A,Filter(Table,Table(MinCategoryEnding Date)<=max(table,Weekending Date)
return
    result

amitchandak
Super User
Super User

@nesselman , if they are not related you can work on selected value or min or max

 

example

 

CALCULATE(SUM(Table2[Inventory]),filter(Table2, table2[CategoryEnding]<=max('TABLE1'[Weekending]) ))

Yes, that worked using "max".  I needed it the other way so I used:

>=MAX

 

nesselman_0-1666169333153.png

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.