Umut K
Umut K

Reputation: 1388

calculated column based on the date dolumn

I have a date column and I want to assign a new calculated column based on that column. I have a measure to assign the min date of the slicer ('Tarihler (Stok)'[Tarih]) which has a relation 1-many with the 'Stok Giriş-Çıkış'[İşlem Tarihi] Both data type are date.

   stok_till_date = calculate(min ('Tarihler (Stok)'[Tarih]),  VALUES('Tarihler (Stok)'[Tarih]))

My formula is

Dönem Başı Stok =
IF (
SELECTEDVALUE ( 'Stok Giriş-Çıkış'[İşlem Tarihi] ) < 'Stok Giriş-Çıkış'[stok_till_date],
( 'Stok Giriş-Çıkış'[Stok Giriş] ),
0
)

which is not calculating correctly.

This is the wrong result when the min date is 01.July.2022

Expected Result :

First column - the sum of the stock before the min slicer date, Second Column - the transaction between the slicer min and max dates - Third Column - Stock at the max date of the slicer (I hope this is more clear)

till date

Result

What am i doing wrong ?

Any ideas ?

Edit : when I add the stok_till_date formula as a column in the table it gives 01.01.2022 not as calculated as in the visual (01.07.2022)

The formula of the minimum date of the slicer returns 01.01.2022

Upvotes: 0

Views: 74

Answers (1)

Mik
Mik

Reputation: 2103

stock Before =
        VAR minDate = MIN('Tarihler (Stok)'[Tarih] )
RETURN
        CALCULATE(
                 SUM('Stok Giriş-Çıkış'[Stok Kalan])
                 ,ALL('Tarihler (Stok)'[Tarih])
                 ,'Tarihler (Stok)'[Tarih]<minDate
        )

Upvotes: 1

Related Questions