Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Cumulative Growth Factor in SSAS Tabular model

Hi Guys, 

 

I am facing new challange in Cumulative Growth Factor in SSAS Tabular model. 

below are the steps.

below is the data:

IDActivation_Date
17772300022/22/18 0:00
17772300032/22/18 0:00
17772700292/27/18 0:00
17780700683/7/18 0:00
17780700693/7/18 0:00
17780600603/6/18 0:00
17780600652/22/18 0:00
17781000803/17/18 0:00
17780600632/27/18 0:00
17781100813/24/18 0:00
17772300012/22/18 0:00
17772600282/22/18 0:00
17780300403/3/18 0:00
17780400412/22/18 0:00
17781400983/14/18 0:00
17781200863/31/18 0:00
17781200883/31/18 0:00
17781300922/22/18 0:00
17781200843/10/18 0:00
17781200893/12/18 0:00

step 1 : Customer_Count:= count(ID)

step2 :cumulative_Customer:= CALCULATE(COUNT(CLIENT_SERVICE_SETUP[CLIENT_ID]),
FILTER(ALLSELECTED('CLIENT_SERVICE_SETUP'),CLIENT_SERVICE_SETUP[ACTIVATION_DATE]<=MAX(CLIENT_SERVICE_SETUP[ACTIVATION_DATE])))

Step 3: Cumulative_Growth:= calculate(divide(customer Count,cummulative_Customer))

below is the output data.

MonthCumulative Growthcumulative CustomerCustomer Count
Feb-1814343
Mar-180.522222229047
Apr-180.2372881411828
May-180.2531645615840
Jun-180.0813953517214
Jul-180.049723761819
Oct-180.042328041898
Nov-180.0156251923
Jan-190.005181351931
Feb-190.010256411952
Mar-190.015151521983
May-190.0660377421214

 My Requirement is : (customer count/cumulative customer), the results are good. but need small change in above requirement. 

my Requirement:  Customer_Count/lag(Cumulative_Customer)

1)

may-18: customer_Count: 47

Feb-18: cummulative_Customer: 43

calculation is : 47/43.

2)

Apr-18: customer_Count: 28

Mar-18: cummulative_Customer:90

calculation : 28/90

 

I am not able to get : Customer_Count/lag(Cumulative_Customer) how to achieve this result.

would some one help me in this regards,

Please let me know if you need any more details.

                         

Regards,

SKM

 
9 REPLIES 9
Anonymous
Not applicable

I believe you can use DATEADD()

 

I.e. growth = [Customer Count] / CALCULATE( [Customer Cummulative], DATEADD( Calendar[DateDateTime], -1, MONTH))

 

If this works then please mark it as the accepted solution.

Anonymous
Not applicable

Hi Nskv,

 

Thanks a lot for your great help!

provide DAX query works fine, in my requirement i have to drill up value(Measure) for year, Quarter and Month in Line chart visual. to get that, Dateadd function hope we can't specify month, we have to find other options to get generic date where i can drill down to year, Quarter and Month. would you please help me in this regards.

 

Regards,

SKM

Anonymous
Not applicable

Try this:

value cummulative (t-1) =
VAR __dateFilterM = STARTOFMONTH( 'DimCalendar'[DateDateTime])
VAR __dateFilterQ = STARTOFQUARTER( 'DimCalendar'[DateDateTime])
VAR __dateFilterY = STARTOFYEAR( 'DimCalendar'[DateDateTime])

RETURN
CALCULATE(
    [value];
    FILTER(
        ALL('DimCalendar');
        SWITCH(
            TRUE();
            ISFILTERED( 'DimCalendar'[CalendarMonthName]); 'DimCalendar'[DateDateTime] < __dateFilterM;
            ISFILTERED( 'DimCalendar'[CalendarQuarterName]); 'DimCalendar'[DateDateTime] < __dateFilterQ;
            'DimCalendar'[DateDateTime] < __dateFilterY
        )
    )
)

 

Anonymous
Not applicable

Hi Nskv,

 

Thanks a lot for your query, the query is perfectly working for Month and Year. for Quarter hope we need some correction, results for quarter is not correct. refer below data, for year 2018 Q1, Q2, Q3, Q4 values are blank. 

I am also trying to get quarter results, once final query is ready i will reply with soultion accepted.

mean while if possible would you please help me in this regards,

my Query.

Running Total Percentage:=
VAR __dateFilterY = STARTOFYEAR('CLIENT_SERVICE_SETUP'[ACTIVATION_DATE])
VAR __dateFilterQ = STARTOFQUARTER('CLIENT_SERVICE_SETUP'[ACTIVATION_DATE])
VAR __dateFilterM = STARTOFMONTH('CLIENT_SERVICE_SETUP'[ACTIVATION_DATE])
RETURN
CALCULATE([cumulative_Customer], FILTER(ALLSELECTED('CLIENT_SERVICE_SETUP'),
SWITCH(TRUE(),
ISFILTERED('CLIENT_SERVICE_SETUP'[Year]),'CLIENT_SERVICE_SETUP'[ACTIVATION_DATE] < __dateFilterY,
ISFILTERED('CLIENT_SERVICE_SETUP'[Quarter]),'CLIENT_SERVICE_SETUP'[ACTIVATION_DATE] < __dateFilterQ,
ISFILTERED('CLIENT_SERVICE_SETUP'[Month]),'CLIENT_SERVICE_SETUP'[ACTIVATION_DATE] < __dateFilterM)))

 

YearQuarterMonthcumulative_CustomerRunning Total PercentageCumulative Growth Final
2018Qtr 1 2018Feb-1843  
2018Qtr 1 2018Mar-1890  
2018Qtr 2 2018Apr-18118  
2018Qtr 2 2018May-18158  
2018Qtr 2 2018Jun-18172  
2018Qtr 3 2018Jul-18181  
2018Qtr 4 2018Oct-18189  
2018Qtr 4 2018Nov-18192  
2019Qtr 1 2019Jan-191931920.520833333
2019Qtr 1 2019Feb-191951921.5625
2019Qtr 1 2019Mar-191981923.125
2019Qtr 2 2019May-1921219210.41666667
2019Qtr 2 2019Jun-1923519222.39583333
2019Qtr 3 2019Jul-1924419227.08333333
2019Qtr 3 2019Aug-1927119241.14583333
2019Qtr 3 2019Sep-1931619264.58333333
2019Qtr 4 2019Oct-1931919266.14583333
2019Qtr 4 2019Nov-1932319268.22916667
2019Qtr 4 2019Dec-1933319273.4375

 

Regards,

SKM

Anonymous
Not applicable

Hmm... I can see some differences between our measures, but I do not know if these differences are causing the issues.

 

  1. I have a date-table, which I believe you should implement as well. If you already have it then you should be referencing the date table where you have written ACTIVATION_DATE.
  2. Switch checks from the top, thus in your query it checks if [Year] is filtered, and if this is true then it do not care if you have filtered by quarter or month as well. I would therefore start by month then quarter and then year - this should then work when you use drill down (i.e. in the matrix not the table).

Hope this helps!

Anonymous
Not applicable

Hi @Anonymous 

 

Is the issue fixed?

Anonymous
Not applicable

Hi Nskv,

 

As suggeted by you, i have taken new Date dim table and extracted new columns with year, Quarter & Month. in Power Bi i have choosen Line Chart, in Axis we placed year, Quarter & Months and in Value below query measure. when we drill down, Month is working fine and quarter is not working as expected, i am still working on this.

if possbile would you please suggest some other option.

 

Running Total Percentage:=
VAR __dateFilterM = STARTOFMONTH('DIM_CALENDER_DATE'[date])
VAR __dateFilterQ = STARTOFQUARTER('DIM_CALENDER_DATE'[date])
VAR __dateFilterY = STARTOFYEAR('DIM_CALENDER_DATE'[date])
RETURN
CALCULATE([cumulative_Customer], FILTER(ALLSELECTED('DIM_CALENDER_DATE'),
SWITCH(TRUE(),
ISFILTERED('DIM_CLIENT_SERVICE_SETUP'[Month]),'DIM_CALENDER_DATE'[date] < __dateFilterM,
ISFILTERED('DIM_CLIENT_SERVICE_SETUP'[Quarter]),'DIM_CALENDER_DATE'[date] < __dateFilterQ,
ISFILTERED('DIM_CLIENT_SERVICE_SETUP'[Year]),'DIM_CALENDER_DATE'[date] < __dateFilterY)))

 

Regards,

SKM

v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

Based on your description, you may click 'Edit Query', go to Query Editor, choose 'Add Column' ribbon, select 'Index Column', click 'Close and Apply'.

d1.png

 

Then you may create the measure as follows.

 

return CALCULATE(
         SUMX(
             ALLSELECTED('Table'),
         DIVIDE(
                CALCULATE(
                    SUM('Table'[Customer Count]),
                    'Table'[Index] = _index+1
                ),
                SUM('Table'[Cumulative Customer])
        )
))

 

 

Result:

d2.png

 

If I misunderstand your thought, please show me your expected output. I am glad to solve the problem for you.

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi Allan,

Thanks a lot for your great help. your understanding is correct but DAX which you shared not able to execute in SSAS tabular cube. in my requirement i need to add 1 more point that we need to implement cumulative total on Month & Quarter

 

formula :

Curren_month[cummulative_customer]-previous_month[cummulative_Customer]/previous_month[cummulative_Customer]

 

example: 

Jan-18: cummulative_Customer: 47

Feb-18: cummulative_Customer: 43

calculation: 43-47/43

 

Note: we need to consider only cummulative_customer measure.

 

i have attached pbix file with to get more clarity.

https://www.dropbox.com/s/a92hq4dqejykhg1/Client_Details.pbix?dl=0  

 

would you please let us know any more details required.

Regards,

SKM

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.