Reputation: 478
I have a below matrix. I want to calculate the % Growth over month
and to show in a matrix
Fields
Expected Output
Company | August | September | GOLM % | Total |
---|---|---|---|---|
EBS-EASEBUSINESS SOLUTIONS | 5940 | 0 | -100% | 5940 |
SWEETREAT CAFE | 5940 | 0 | -100% | 5940 |
M/S SPORTS ONE PHARMACY | 1188 | -100% | 1188 |
Tried Solution
I have tried this Solution. But it's not working for me
GOLM =
VAR SelectedMonth =
SELECTEDVALUE (
Dates[Month],
MONTH ( TODAY () )
)
VAR PrevMonth =
SELECTEDVALUE (
'Source Data'[Month Updates],
MONTH ( TODAY () )
) - 1
VAR Growth =
CALCULATE(
DIVIDE(
SelectedMonth - PrevMonth,
PrevMonth,
0
)
)
RETURN
IF(
SELECTEDVALUE('Source Data'[Month Updates]) = PrevMonth,
SUM('Source Data'[SALES VALUE]),
IF(
SELECTEDVALUE('Source Data'[Month Updates]) = SelectedMonth,
SUM('Source Data'[SALES VALUE]),
FORMAT(Growth, "Percent")
)
)
Error
DAX File
Here is my Dax File
Upvotes: 1
Views: 2882
Reputation: 7334
You should be able to add a measure in the Source Data Table itself like below:
GLM =
VAR Curr_Month =
CALCULATE (
SUM ( 'Source Data'[SALES VALUE] ),
'Source Data'[Month Updates] = FORMAT ( EOMONTH ( TODAY (), 0 ), "mmmm" )
)
VAR Prev_Month =
CALCULATE (
SUM ( 'Source Data'[SALES VALUE] ),
'Source Data'[Month Updates] = FORMAT ( EOMONTH ( TODAY (), -1 ), "mmmm" )
)
VAR GROWTH = ( Curr_Month - Prev_Month ) / Prev_Month
RETURN
GROWTH
and of course, you need to change the format of the measure to PERCENTAGE.
Is this what you're looking for?
Upvotes: 0
Reputation: 1024
Maybe you can do something like this;
First create a DAX table by using modelling pane;
Growth =
VAR CurrentMonth = FORMAT(TODAY(), "MMMM")
VAR PrevMonth = FORMAT(EOMONTH(TODAY(),-1), "MMMM")
VAR tmp1 = SELECTCOLUMNS('Source Data',
"SV_PrevMonth", CALCULATE(
SUM('Source Data'[SALES VALUE]),
'Source Data'[Month Updates]=PrevMonth),
"SV_CurrentMonth", CALCULATE(
SUM('Source Data'[SALES VALUE]),
'Source Data'[Month Updates]=CurrentMonth),
"PN", 'Source Data'[ProductNameFull],
"CN", 'Source Data'[CustomerNameFull],
"CP", 'Source Data'[Company]
)
return tmp1
Then add a measure to your table
GrowthPercentage = CALCULATE(DIVIDE(SUM(Growth[SV_CurrentMonth]) - SUM(Growth[SV_PrevMonth]), SUM(Growth[SV_PrevMonth]),0))*100
The result wil be like;
Upvotes: 1