total measure
4 Topicsdax calculation total is incorrect
im trying to calculate return on investement for stocks data based on the formula ( current price-initial cost)/initial cost. i calculated first the initial cost ( purchased amount * number of stocks purchased) then the current position price as: (current price* number of stocks purchased) and finally i want to get Profit/Loss amount and Profit/Loss %. simply i subtracted : current price-initial cost and for the percentage i calculated it as:( current price-initial cost)/initial cost. the result is correct for indivisual stock but the overall total purchased amount value, Profit/Loss value and percentage is incorrect in the total , it's taking the sum(last closing price) * sum (number of stocks purchased): 53*135934=7204502 which is wrong. the correct result should be the sum of column 4693.579996 which is the sum of all values in the amount purchased column. the line chart is also showing incorect percentages in the overall return but only correct values for indiviual stocks the used DAX measures amount purchased value = CALCULATE(SUM('user portfolio'[number of stocks purchased])*[last closing price]) p&l = CALCULATE([amount purchased value]-SUM('user portfolio'[Amount Purchased])) p&l % = CALCULATE(([amount purchased value]-SUM('user portfolio'[Amount Purchased]))/SUM('user portfolio'[Amount Purchased]),FILTER('stocks data','stocks data'[date diff]>=0)) puchasing date diff column = DATEDIFF(RELATED('user portfolio'[Date Purchased]),'stocks data'[Date],DAY) any idea on how to fix the calculation to show the correct overall profit/loss value and percetage? note: when calcuting ROI there are other things taken into consideration like : dividend, commission fees, etc. and this example is just a simple case 🙂Solved1.3KViews0likes4CommentsTotal value coming from measure is wrong
Hello, I developed this measure: CALCULATE(if([COUNTReport]=2, DIVIDE(SUM(FactOTDJnJPap[measurevalue]),2), SUM(FactOTDJnJPap[measurevalue])), FactOTDJnJPap[IDTypeReportJnJPharma] IN {1,5}) The row values are correct but the total is wrong, the value should be around 9,2. In the next image I explain better what I have now coming from the Fact and what I need to calculate. I have a line chart with the values for every Site (this one is showing the correct values) and another one with the total value divided by the number of sites (it's not always the same number) for that month. Really appreciate your help, I'm stucked with this for 2 days. Thanks is advance.Solved1.3KViews0likes6CommentsSumx function isn't working
Hi there, please help me. my sumx function isnt working for a total qty measure i calculated. I have my Qty measure where I am replacing my empty rows with the previous values as such final Qty = VAR CurrentValue = SUM ( data[qty]) VAR PreviousValue = if( sum(data[qty]) = BLANK(), CALCULATE( sum(data[qty]), date[date_dt] = MAX(date[date_dt])-1, )) RETURN if( max(date[date_dt]) =max(date[date_dt]) , CurrentValue + PreviousValue, CurrentValue ) When I put this total on my table view, I dont get the iterative total by the dates as I would like to see. It is giving me the total qty logic as if I was jusr doing a sum(qty). Iterative Qty = sumx(values(date[date_dt]), [final Qty]) (this should add up all the values on the views itself but when I look at it, the rows are correct but the total is still wrong. I had to export it to excel and noticed its not working) Any other way to add my iterative values for my view?Solved1.9KViews0likes3CommentsTotal Measure by Group
Legal Entity EDI eStore Manual Grand Total * USA 43,763 198,983 371,231 613,977 Australia 7,904 4,503 20,714 33,121 Brazil 215 20,450 20,665 Canada 4,394 34,116 38,510 I have a matrix visual like this in Power BI. The Grand Total for the rows calculates and displays, but I think I need a measure to calculate the row total in order to derive the percent of total in each row by Order Category (EDI, eStore, Manual). In the end, the matrix will look like this: Legal Entity EDI eStore Manual * USA 7.1% 32.4% 60.5% Australia 23.9% 13.6% 62.5% Brazil 0.0% 1.0% 99.0% Canada 0.0% 11.4% 88.6% What measures do I need to write to accomplish this?Solved690Views0likes1Comment