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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
krrish116
Resolver II
Resolver II

Average of Total Year should display for all Months

Hi @amitchandak ,

Please help me in sort out this.

I have a table which contains 3 columns

     

DateSales 1Sales 2Sales1 - Sales2Average / Year
2018-011,279.00603.00676.00653.00
2018-021,315.00563.00752.00653.00
2018-031,301.00576.00725.00653.00
2018-041,308.00607.00701.00653.00
2018-051,334.00673.00661.00653.00
2018-061,326.00642.00684.00653.00
2018-071,300.00657.00643.00653.00
2018-081,296.00654.00642.00653.00
2018-091,281.00690.00591.00653.00
2018-101,273.00687.00586.00653.00
2018-111,152.00530.00622.00653.00
2018-121,039.00486.00553.00653.00
2019-011,042.00484.00558.00439.75
2019-021,059.00520.00539.00439.75
2019-031,068.00553.00515.00439.75
2019-041,080.00583.00497.00439.75
2019-051,053.00557.00496.00439.75
2019-06953.00482.00471.00439.75
2019-07976.00514.00462.00439.75
2019-08922.00469.00453.00439.75
2019-09863.00498.00365.00439.75
2019-10870.00513.00357.00439.75
2019-11843.00539.00304.00439.75
2019-12825.00565.00260.00439.75

 

Now here the problem is i have to calculate the sum of sales1-sales2 for every year individually and divide it with 12 to show average / year

 

ex: sum of sales1-sales2 from 2018-01 to 2018-12 is 7836 and divide it with 12 and show value 653 in Average/year in a table and graph visual.

 

sum of sales1-sales2 from 2019-01 to 2019-12 is 5277 and divide it with 12 and show value 439.75in Average/year in a table and graph visual.

 

Please help me in sortout this issue.

I have created a measure 

Average/ Year = CALCULATE(sum[Sales1-Sales2], DATESYTD('Date'[Date]))
but it is not working out.
 
Please help me.
Thanks,
Krish....
 
1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @krrish116 

You can try calculated columns as below:

 

Year = YEAR('Table'[Date])
Average / Year = CALCULATE(SUM('Table'[Sales1 - Sales2]),ALLEXCEPT('Table','Table'[Year]))/12

 

75.png

Please check my sample file for more details.

Best Regards,
Community Support Team _ Eason

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi, @krrish116 

You can try calculated columns as below:

 

Year = YEAR('Table'[Date])
Average / Year = CALCULATE(SUM('Table'[Sales1 - Sales2]),ALLEXCEPT('Table','Table'[Year]))/12

 

75.png

Please check my sample file for more details.

Best Regards,
Community Support Team _ Eason

amitchandak
Super User
Super User

@krrish116 , Try a new measure like

 

CALCULATE(AverageX(values('Date'[Month Year]) ,calculate(sum(Table[Sales1])-SUm(Table[Sales2]))), DATESYTD('Date'[Date]))

It is not working ..

I have to show same average value for all 12 months ..

ex: sum of sales1-sales2 from 2018-01 to 2018-12 is 7836 and divide it with 12 and show value 653 in Average/year in a table and graph visual.

 

sum of sales1-sales2 from 2019-01 to 2019-12 is 5277 and divide it with 12 and show value 439.75in Average/year in a table and graph visual.

@krrish116 , Rolling 12

 

example 

Rolling 12 = calculate(AverageX(Values('Date'[MONTH Year]),CALCULATE(sum(Sales[Sales Amount])),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,Month ))

 

 

Rolling 12 = divide( CALCULATE(sum(Sales[Sales]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-12,MONTH)) ,
CALCULATE(distinctCOUNT('Date'[Month Year]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH), filter(Sales,not(isblank(sum(Sales[Sales]))))))

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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