YTD for each asset on a table (Data filtering - Dax)

Imagine a table with 3 columns:

Date AssetType Value
2022-01-01 A 1
2022-01-02 A 1.02
2022-01-03 A 1.05
2022-01-04 A 1.09
2022-01-05 A 1.06
2022-01-03 B 1
2022-01-04 B 1.05
2022-01-05 B 1.07
2022-01-06 B 1.09
2022-01-07 B 1.08

The First date of 2022 for each asset is diferent.

I want to create a new column or measure that returns the first date of 2022 for both assets.

So far i've tried to use = CALCULATE(STARTOFYEAR(table[date])), FILTER(Table, Table[AssetType] = [Asset type]

Obs. [Asset Type] is a measure tha giver me the type of asset.

But is returning the same date for both assets (2022-01-01)

Does anyone knows how get this done ?

Date AssetType Value FirstDate
2022-01-01 A 1 2022-01-01
2022-01-02 A 1.02 2022-01-01
2022-01-03 A 1.05 2022-01-01
2022-01-04 A 1.09 2022-01-01
2022-01-05 A 1.06 2022-01-01
2022-01-03 B 1 2022-01-03
2022-01-04 B 1.05 2022-01-03
2022-01-05 B 1.07 2022-01-03
2022-01-06 B 1.09 2022-01-03
2022-01-07 B 1.08 2022-01-03

Thx

Upvotes: 1

Views: 63

Answers (1)

Ozan Sen
Ozan Sen

Reputation: 2615

OK. This Time create a calculated column and paste this code:

FirstDate =
CALCULATE (
    MIN ( YourTable[Date] ),
    ALLEXCEPT ( YourTable, YourTable[AssetType] )
)

The result :

FG

Upvotes: 1

Related Questions