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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Hamdi-FAKHFAKH
New Member

calculate the stock total between the current line date and first purchase date

I try with calculated but it doesn't work, can I have some help

HamdiFAKHFAKH_0-1663341880641.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Hamdi-FAKHFAKH ,

 

Here are the steps you can follow:

1. Create calculated column.

 

Total stock = 
var _mindate=MINX(FILTER(ALL('Table'),'Table'[somme des achats]=EARLIER('Table'[somme des achats])), 'Table'[DATE])
var _currentdate='Table'[DATE]
return
SUMX( 
    FILTER(ALL('Table'),
    'Table'[DATE]>=_mindate&&'Table'[DATE]<=EARLIER('Table'[DATE])
    &&
    'Table'[somme des achats]=EARLIER('Table'[somme des achats])
    ),[somme des achats])

 

2. Result:

vyangliumsft_0-1664412091574.png

 

Best Regards,

Liu Yang

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

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi  @Hamdi-FAKHFAKH ,

 

Here are the steps you can follow:

1. Create calculated column.

 

Total stock = 
var _mindate=MINX(FILTER(ALL('Table'),'Table'[somme des achats]=EARLIER('Table'[somme des achats])), 'Table'[DATE])
var _currentdate='Table'[DATE]
return
SUMX( 
    FILTER(ALL('Table'),
    'Table'[DATE]>=_mindate&&'Table'[DATE]<=EARLIER('Table'[DATE])
    &&
    'Table'[somme des achats]=EARLIER('Table'[somme des achats])
    ),[somme des achats])

 

2. Result:

vyangliumsft_0-1664412091574.png

 

Best Regards,

Liu Yang

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

Hamdi-FAKHFAKH
New Member

@tamerj1 I already try the same problem

@Hamdi-FAKHFAKH 
Use 

=
CALCULATE (
    SUM ( 'Table'[Column] ),
    'Table'[Date] <= EARLIER ( 'Table'[Date] ),
    ALL ( 'Table' )
)

HamdiFAKHFAKH_0-1663353797783.png

the same problem 😔

@Hamdi-FAKHFAKH 
Sorry for that. Please try

=
VAR CurrentDate = 'Table'[Date]
VAR T1 =
    FILTER ( 'Table', 'Table'[Date] <= CurrentDate )
RETURN
    SUMX ( T1, 'Table'[Column] )
tamerj1
Super User
Super User

Hi @Hamdi-FAKHFAKH 
Try to replace BLANK ( ) with MIN ( [Date] )

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.