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
S-Learner
New Member

Error: Y-o-Y Calculation

Hi guys,

 

I would to create a table for showing the retail sales value and volume (like below), as well as the % change vs Sep 2021(Y-o-Y). However, I got some issues on Y-o-Y calculation.

 

DateType of OutletsRetail Sales Value($M)Retail Sales value_% Change vs Sep 2021Volume IndexVolume Index_% Change vs Sep 2021
Sep 2022All retail outlets                            28,0720.20%96.7-1.50%

 

For the retail sales value, volume index and volume_% Change vs 2021, they all come from the dataset and their data type are decimal number.  

 

SLearner_2-1669568829160.png

 

Therefore, I just need to set up a DAX formula for calculating the retail sales value vs Sep 2021(Y-o-Y).

 

SLearner_5-1669569307122.png

 

However, the table showed some errors when I added the Volume Index and % Change vs Sep 2021 for Volume Index field into the table:

- Couldn't calculate the % change vs Sep 2021 of retail sales value

- There was an extra row with wrong figures.

 

SLearner_7-1669569797136.pngh

 

Could anyone suggest some solutions to solve out the above problems?

 

Thank you.

 

 

 

 

 

 

 

 

5 REPLIES 5
v-rongtiep-msft
Community Support
Community Support

Hi @S-Learner ,

Although you have provided the dax formula and picture with the data, I am not familiar with the measures. How the measures calculate? Could you please provide your pbix file without privacy information and desired output with more details.

 

How to Get Your Question Answered Quickly 

 

Best Regards
Community Support Team _ Polly

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

Hi, 

 

Thanks for your help! Please find the below pbix file and the raw data.

pbix file 

Raw data 

 

Actually, I would like to use Power PI to automate the the data processing and create the below table. The desire output should show the value & volume index, as well as their %Change vs. Sep 2021 (Y-o-Y) and %Change vs. Sep 2018. Please note that the % change of volume should refer to the raw data. 

 

SLearner_2-1669621056407.png

 

Thank you.

 

 

 

 

Hi @S-Learner ,

I have created a simple sample, please refer to it to see if it helps you.

Create a measure.

Measure = var _1= EDATE(MAX('Retail Sales'[Date]),-12)
var _2=CALCULATE(SUM('Retail Sales'[Value]),FILTER(ALL('Retail Sales'),'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])&&'Retail Sales'[Date]=_1))
return 
(MAX('Retail Sales'[Value])-_2)/_2

 

vpollymsft_2-1669626005545.png

Best Regards
Community Support Team _ Polly

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

Hi, 

 

Thanks for your great help. I have also tried to calculate the Jan-Sep 2022 Y-o-Y and Jan- Sep 2022 vs Jan-Sep 2018, but I couldn't capture the period Jan- Sep 2018 and Jan-Sep 2022 by using the below formula and apply it to your pervious Y-o-Y DAX formula.... Could you please let me any errors did i made for the below DAX formula ?  Also, I have attached the pbix file for you.

 

pbix file 

 

New formula for Volume index _ Jan-Sep 2022 Y-o-Y

Volume Index_YTD% Change vs Sep 2021 = var _1= EDATE(MAX('Retail Sales'[Date]) && 'Retail Sales'[Date] <= MAX('Retail Sales'[Date]),-12)
var _2=CALCULATE(SUM('Retail Sales'[Volume Index]),FILTER(ALL('Retail Sales'),'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])&&'Retail Sales'[Date]=_1))
return
(MAX('Retail Sales'[Volume Index])-_2)/_2
 
My desire output:
Major Type of Retail OutletValueValue_% change Jan-Sep 2022 vs. Jan-Sep 2021Volume_% change Jan-Sep 2022 vs. Jan-Sep 2021Value_% change Jan-Sep 2022 vs. Jan-Sep 2018Volume_% change Jan-Sep 2022 vs. Jan-Sep 2018
All retail outlets28,072-1.30%-4.20%-29.50%-34.30%
 
Thanks again !
 
 
 

Hi @S-Learner ,

Please have a try.

Create 2 columns first.

month_1 = MONTH('Retail Sales'[Date])
Year _1 = YEAR('Retail Sales'[Date])

Then create 4 measures.

2018value = var _now=CALCULATE(SUM('Retail Sales'[Value]),FILTER(ALL('Retail Sales'),'Retail Sales'[Year _1]=SELECTEDVALUE('Retail Sales'[Year _1])&&'Retail Sales'[month_1]>=1&&'Retail Sales'[month_1]<=9&&'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])))
var _before=CALCULATE(SUM('Retail Sales'[Value]),FILTER(ALL('Retail Sales'),('Retail Sales'[Year _1]=SELECTEDVALUE('Retail Sales'[Year _1])-4)&&'Retail Sales'[month_1]>=1&&'Retail Sales'[month_1]<=9&&'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])))
return
(_now-_before)/_before
2018volumn = var _now=CALCULATE(SUM('Retail Sales'[Volume Index]),FILTER(ALL('Retail Sales'),'Retail Sales'[Year _1]=SELECTEDVALUE('Retail Sales'[Year _1])&&'Retail Sales'[month_1]>=1&&'Retail Sales'[month_1]<=9&&'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])))
var _before=CALCULATE(SUM('Retail Sales'[Volume Index]),FILTER(ALL('Retail Sales'),('Retail Sales'[Year _1]=SELECTEDVALUE('Retail Sales'[Year _1])-4)&&'Retail Sales'[month_1]>=1&&'Retail Sales'[month_1]<=9&&'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])))
return
(_now-_before)/_before
2021value = var _now=CALCULATE(SUM('Retail Sales'[Value]),FILTER(ALL('Retail Sales'),'Retail Sales'[Year _1]=SELECTEDVALUE('Retail Sales'[Year _1])&&'Retail Sales'[month_1]>=1&&'Retail Sales'[month_1]<=9&&'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])))
var _before=CALCULATE(SUM('Retail Sales'[Value]),FILTER(ALL('Retail Sales'),('Retail Sales'[Year _1]=SELECTEDVALUE('Retail Sales'[Year _1])-1)&&'Retail Sales'[month_1]>=1&&'Retail Sales'[month_1]<=9&&'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])))
return
(_now-_before)/_before
2021volumn = var _now=CALCULATE(SUM('Retail Sales'[Volume Index]),FILTER(ALL('Retail Sales'),'Retail Sales'[Year _1]=SELECTEDVALUE('Retail Sales'[Year _1])&&'Retail Sales'[month_1]>=1&&'Retail Sales'[month_1]<=9&&'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])))
var _before=CALCULATE(SUM('Retail Sales'[Volume Index]),FILTER(ALL('Retail Sales'),('Retail Sales'[Year _1]=SELECTEDVALUE('Retail Sales'[Year _1])-1)&&'Retail Sales'[month_1]>=1&&'Retail Sales'[month_1]<=9&&'Retail Sales'[Type of Outlets]=SELECTEDVALUE('Retail Sales'[Type of Outlets])))
return
(_now-_before)/_before

vpollymsft_0-1669700236412.png

Best Regards
Community Support Team _ Polly

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

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.