Hi Vidas,
Forgive me if I can ask a question. Feel free to send me onto researching on PowerBi forums.
I am looking to show some trading metrics as attached
As an attempt to code this with new measures in Power BI I have created the following measures:
* $ Sales Capital Gain = IF('Report'[Sales Capital Gain]<0,'Report'[Sales Capital Gain],0)
* $ Sales Capital Loss = IF('Report'[Sales Capital Gain]>0,'Report'[Sales Capital Gain],0)
* Sales Capital Gain = IF('Report'[Sales Capital Gain]<0,1,0)
* Sales Capital Loss = IF('Report'[Sales Capital Gain]>0,1,0)
I have created a copy of your Sales Tab and deleted “Sales Days Since Latest Buy” & “Latest Sell Date” and inserted the above measures.
Whilst the above work and shows a split between Profits & Losses in separate columns and similar a “1” against a transaction in separate columns for Loss or gain I am having an issue in having a total of these 4 columns. As an example, the total gain is showing as a total, Say, as an example, $8,000 in the loss column and zero in the gain rather than $12,000 Gain and $4,000 loss columns
See attached report from PowerBI
Any guidance will be appreciated, however feel free to say if I am asking too much of you.
Comments
It appears to me that to solve what you want, you need to force calculation to some level, for example - Day + account + symbol. Now when you check "Sales Capital Gain" SCG, you are checking at the final SCG for selected period. If you would force that to specific Day + account + symbol, you would check one sales transaction as you probably want.
Example:
Sales Capital Gain =
SUMX(Dates[Day]
, SUMX(Account[Account]
, SUMX(Symbol[Symbol
, IF('Report'[Sales Capital Gain]<0,'Report'[Sales Capital Gain],0)
)))
Note - this code is not tested, just for you to get an idea.