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

Rolling 12 Percent Change Grouped by Customer

Please help! I've been working with this for awhile and I cannot figure it out.

 

My company utlizes Rolling 12 Months for statistics. I grouped my data using these months to determine year (i.e., August-September for 2018-2019 would be year 12 and August-September of 2019-2020 would be year 13). I was also able to determine the total sales for each year. Further, I can determine for each business, what their total sales were for the rolling 12 year by grouping the rows. However, when I try to determine the percent change of each of these customers between rolling 12 years, I am unable to get it done.

 

I have tried calculated columns, but I get a circular reference error. I've tried creating new tables, but my relationships are not accurate then. Am I missing something? Can someone who is DAX savvy help me out? This has been an open topic for the database for awhile now.

 

Here's a sample of what I am looking for. Formatting can change as needed because I know that it will be easier to code subtraction of 2 columns rather than rows, but this is the information that I need:

 

YearLabelRoling12YearCustomerNameTotalSalesSumDifferencePercentChange
Year 132019-2020Customer A$100,000$50,0050%
Year 122018-2019Customer A$50,000  
Year 132019-2020Customer B$500,000$100,00025%
Year 122018-2019Customer B$400,000  
1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Anonymous,

 

Try this approach. I recommend adding YearNum (e.g., 12, 13) to your date table; this will enable you to calculate more easily. The date table should be joined to the fact table.

 

Measures:

 

Total Sales = SUM ( RollingTest[Sales] )

PY Sales = 
VAR vYearNum =
    MAX ( DateTest[YearNum] )
VAR vResult =
    CALCULATE ( [Total Sales], FILTER ( ALL ( DateTest ), DateTest[YearNum] = vYearNum - 1 ) )
RETURN
    vResult

Percent Change = DIVIDE ( [Total Sales] - [PY Sales], [PY Sales] )

 

Output:

 

DataInsights_0-1600201361569.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Take our rolling year into a new table and create a rank on that

column in year Table

Year Rank = RANKX(all('Year '),'Year '[rolling year],,ASC,Dense)

 

New measures
This Year = CALCULATE(sum('Table'[TotalSales]), FILTER(ALL('Year '),'Date'[Year Rank]=max('Year '[Year Rank])))
Last Year = CALCULATE(sum('Table'[TotalSales]), FILTER(ALL('Year '),'Date'[Year Rank]=max('Year '[Year Rank])-1))

DataInsights
Super User
Super User

@Anonymous,

 

Try this approach. I recommend adding YearNum (e.g., 12, 13) to your date table; this will enable you to calculate more easily. The date table should be joined to the fact table.

 

Measures:

 

Total Sales = SUM ( RollingTest[Sales] )

PY Sales = 
VAR vYearNum =
    MAX ( DateTest[YearNum] )
VAR vResult =
    CALCULATE ( [Total Sales], FILTER ( ALL ( DateTest ), DateTest[YearNum] = vYearNum - 1 ) )
RETURN
    vResult

Percent Change = DIVIDE ( [Total Sales] - [PY Sales], [PY Sales] )

 

Output:

 

DataInsights_0-1600201361569.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.