0
votes

This is my first PowerBi report. 

I've a table structure like this

TransDate   UnitsAsOf   Price   InvestedAmount  Stock
01/02/2020  10          12.4    124              APL
01/03/2020  20          13      260              APL
01/05/2020  21          15      315              APL
01/10/2020  1           111     111              BPL

And this is the table Visualization I'm creating

Stock   Total invested (Summarized column)  Current Value
APL     699                                 THIS IS A MEASURE column
BPL     111 

I just couldn't figure out how to get max(transDate) for each stock and multiple it with the Price of that row?

Any help please?

2

2 Answers

0
votes

You can do it like this

measure =
SUMX(TOPN(1, YourTable, YourTable[TransDate], DESC), YourTable[Price] * YourTable[InvestedAmount])

the TOPN will return you the row with the latest date, and in the SUMX you use the fields from that row.

0
votes

OPTION-1

You can simply create this following measure-

max_date = MAX(your_table_name[TransDate])

Now add a table visual with column - Stock, InvestedAmount (Default SUM applied) and New Measure max_date. The output will be as below-

enter image description here

OPTION-2

You can also add all 3 column - Stock, InvestedAmount and TransDate directly and select Latest for TransDate as shown below and the output will be same-

enter image description here