cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
pers
Frequent Visitor

Share Valuation using FIFO method

Hello - I am trying to implement FIFO in share valuation. I was able to get it in excel, but not able to get the calculation in Power BI.

I am including the sample data (input and output) as was done in excel - gdrive link (https://drive.google.com/open?id=1vsc8R5MnGy2MVmqxUI7wgHssl6K6wjgM). The blue header columns in FINAL RESULT are the required output - I need help in creating these columns in Power BI - (a) CAPITAL GAIN (b) STOCK IN HAND © CLOSING VALUE

Also is the link for the PBX file (https://drive.google.com/open?id=1irJ2vOyV50WdVyYU45YQwA12rkqUNojm), where I am not able to fix the Calculated Column - “Cost Basis with FIFO”. Below is the DAX calculation for FIFO method that I am using - which is not working as per FIFO as it is not picking RATE (the multiplication factor) of the BUY QTY - rather it is picking the current row (SALE RATE), which is not the expected behavior of FIFO.

Cost Basis with FIFO =
VAR myUnits=[Qty.]
VAR PreviousBuys=
FILTER(TransactionData,
[IsIn]=EARLIER([IsIn])&&
[Sauda Date]<EARLIER([Sauda Date])&&
([Net Qty.] > 0)
)
VAR PreviousSales=
SUMX(
FILTER(TransactionData,
[IsIn]=EARLIER([IsIn])&&
[Sauda Date]<EARLIER([Sauda Date])&&
([Net Qty.] < 0)
),
[Qty.]
)
VAR PreviousBuysBalance=
ADDCOLUMNS(
ADDCOLUMNS(
PreviousBuys,
“Cumulative”,
SUMX(
FILTER(PreviousBuys,
([Sauda Date]<=EARLIER([Sauda Date]))
),
[Qty.])
),
“Balance Left”,
[Qty.]-IF([Cumulative]<PreviousSales,
[Qty.],
VAR PreviousCumulative=[Cumulative]-[Qty.]
RETURN
IF(PreviousSales>PreviousCumulative,PreviousSales-PreviousCumulative)
)
)
VAR CostUsed=
ADDCOLUMNS
(
ADDCOLUMNS
(
PreviousBuysBalance,
“MyCumulatives”,
SUMX
(
FILTER(PreviousBuysBalance,
([Sauda Date]<=EARLIER([Sauda Date]))
),
[Balance Left])
),“Balance Used”,
IF(
[MyCumulatives]<myUnits,[MyCumulatives],
VAR PreviousCumulatives=[MyCumulatives]-[Balance Left]
RETURN
IF(myUnits>PreviousCumulatives,myUnits-PreviousCumulatives)
)
)
RETURN
IF([Net Qty.] < 0,
([Qty.][Rate])-SUMX(CostUsed,([Balance Used][Rate])))

0 REPLIES 0

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors