Moeez
Moeez

Reputation: 478

Power Bi Calculate Growth Over Last Month and Show it in a Matrix

I have a below matrix. I want to calculate the % Growth over month and to show in a matrix

Sample Screenshot of Matrix visual

Fields

Fields used in Maatrix

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

Error Screenshot

DAX File

Here is my Dax File

Upvotes: 1

Views: 2882

Answers (2)

Gangula
Gangula

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

Kemal Kaplan
Kemal Kaplan

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;

enter image description here

Upvotes: 1

Related Questions