Forum Discussion
Calculating % increase as dollar value - DAX
Hi Natty004
First create the year month sequential number number (Calculated Column)
YearMonth Sequential Number =
RANKX (
'Date',
YEAR ( 'Date'[Date] ) * 100
+ MONTH ( 'Date'[Date] ),
,
ASC,
DENSE
)
Then the required measure would be
$ MArgine Increase =
VAR CurrentMonth =
MAX ( 'Date'[YearMonth Sequential Number] )
VAR CurrentMonthRevenue = [TOTAL Revenue]
VAR CurrentMonthMarginPercent = [Margin %]
VAR PreviousMonthMarginPercent =
CALCULATE ( [Margin %], 'Date'[YearMonth Sequential Number] = CurrentMonth - 1 )
RETURN
CurrentMonthRevenue * ( CurrentMonthMarginPercent - PreviousMonthMarginPercent )- Natty0044 years agoFrequent Visitor
Hello tamerj1
Thank you for your response, I have updated the following however I the $ increase value is the same as the $ margin value.
Here are my updates:
YearMonth Sequential Number = RANKX ( 'Table1', YEAR ('Table1'[Dt Invoice]) * 100 + MONTH ( 'Table1'[Dt Invoice] ), , ASC, DENSE )Measure
$ MArgine Increase = VAR CurrentMonth = MAX ( Table1[YearMonth Sequential Number] ) VAR CurrentMonthRevenue = 'Table1'[Measure : TOTAL Revenue] VAR CurrentMonthMarginPercent = [Measure : Margin %] VAR PreviousMonthMarginPercent = CALCULATE([Measure : Margin %],Table1[YearMonth Sequential Number]=CurrentMonth-1) RETURN CurrentMonthRevenue * ( CurrentMonthMarginPercent - PreviousMonthMarginPercent )The value that returns is the same as the margin $ amount
Measure : Total Margin = Table1[Measure : TOTAL Revenue]-Table1[Measure : Total Oncosts]I have tried to calculate the current Margin % and the pror month margin %, however the results when I am pulling in the Prior month % is the same as current month
Current Month % = CALCULATE( divide(Table1[Measure : Total Margin], Table1[Measure : TOTAL Revenue],0), Table1[YearMonth Sequential Number])Prior Month % = VAR CurrentMonthMargin = CALCULATE([Measure : Margin %], Table1[YearMonth Sequential Number]) VAR PriorMonthMargin = CALCULATE([Measure : Margin %], Table1[YearMonth Sequential Number] -1) RETURN PriorMonthMarginThen I tried to write the following however it did not return any results
$ margin increase = SUMX ( Table1, [Measure : TOTAL Revenue] * ( [Measure : Margin %] - ( CALCULATE ( [Measure : Margin %], Table1[YearMonth Sequential Number] - 1 ) ) ))Apologies for the multiple screen shots, are you able to see where the fault is. I can't seem to increase the dollar amount that has been increased.
Any assitance would be greatly appreciated.
Thank you in advance,
Nat
- Natty0044 years agoFrequent Visitor
Hello tamerji,
Thanks for your response. I have added the above calculations and measures however the
$ margin increase amount is the same value as margin amount.
See below:
YearMonth Sequential Number = RANKX ( 'Table1', YEAR ('Table1'[Dt Invoice]) * 100 + MONTH ( 'Table1'[Dt Invoice] ), , ASC, DENSE )Measure
$ MArgine Increase = VAR CurrentMonth = MAX ( Table1[YearMonth Sequential Number] ) VAR CurrentMonthRevenue = 'Table1'[Measure : TOTAL Revenue] VAR CurrentMonthMarginPercent = [Measure : Margin %] VAR PreviousMonthMarginPercent = CALCULATE([Measure : Margin %],Table1[YearMonth Sequential Number]=CurrentMonth-1) RETURN CurrentMonthRevenue * ( CurrentMonthMarginPercent - PreviousMonthMarginPercent )Margin $ measure
Measure : Total Margin = Table1[Measure : TOTAL Revenue]-Table1[Measure : Total Oncosts]I then tried to calculate current margin % and Prior month Matgin % and add these to the matrix to see if they are calculating correctly.
The current margin % measure below matches the same calculation [Measure : Margin %]
Current Month % = CALCULATE( divide(Table1[Measure : Total Margin], Table1[Measure : TOTAL Revenue],0), Table1[YearMonth Sequential Number])Prior month % - does not pull through the previous month - it just duplicates the current month %
Prior Month % = VAR CurrentMonthMargin = CALCULATE([Measure : Margin %], Table1[YearMonth Sequential Number]) VAR PriorMonthMargin = CALCULATE([Measure : Margin %], Table1[YearMonth Sequential Number] -1) RETURN PriorMonthMarginApologies in advance, are you able to identfy where I am going wrong?
many thanks in advance