Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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])))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |