cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Thomas94401
Frequent Visitor

Cumulative Amount_Spent_Per_Person

Hi, 

 

This is my problem : 

 

I have a table of facts with "Indicateurs" :

- One column Month_Survenance

- One column Amount_Spent

- One column Index_Population (integer)

 

This table is linked with an other table "Population" (connection in both directions) :

- One column Index_Population

- One column Population

And this table is also linked with a Date Table :
- One column Month_Survenance

- One column End_Month_Survenance

 

I also create a disconnected table "Coding Month" : 

Diff_Min_SlicerLabel_Month
0M01
1M02
2M03
3M04
4M05
5M06
6M07

 

Thomas94401_0-1635957846693.png

 

The objective is to calculate the average amount spent per person month by month, and then to calculate a column that aggregates these amounts : 

 

Thomas94401_1-1635957936806.png

I want to create a measure"Cumulative_Amount_Spent_Per_Person" which should look like this : 

Label_MonthCumulative_Amount_Spent_Per_Person
M01267,57
M02487
M03696
M04...
M05...
M06...

 

The measures I have constructed are:

 

Total_Amount_Spent =
 
         VAR Slicer_Periode = MIN(Coding_Month[Diff_Avec_Min_Slicer])
 
         VAR EOMMinSlicerDate = EOMONTH(MIN(Date_survenance[Mois_survenance]), Slicer_Periode)

RETURN
          CALCULATE(
                 SUM(Indicateurs[Amount_Spent]),
                 EOMMinSlicerDate = Date_survenance[End_Month]
           )
---------------------------------------------
Total_Population =
 
         VAR Slicer_Periode = MIN(Coding_Month[Diff_Avec_Min_Slicer])
 
         VAR EOMMinSlicerDate = EOMONTH(MIN(Date_survenance[Mois_survenance]), Slicer_Periode)

RETURN
          CALCULATE(
                 SUM(Populations[Population]),
                 EOMMinSlicerDate = Date_survenance[End_Month]
           )
---------------------------------------------
Amount_Spent_Per_Person = DIVIDE([Total_Amount_Spent], [Total_Population], 0)
 
Thank you in advance for your help! If the measuresI have built are not good, feel free to suggest better measurements !
1 REPLY 1
v-easonf-msft
Community Support
Community Support

Hi, @Thomas94401 

Are you calculating the cumulative value month by month? If possible, can you provide a simple file for us to test and provide accurate solutions.

You can also check if the solution in this thread could work for you.

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Calculating-cumulative-stock-value/td-p/21723... 

https://community.powerbi.com/t5/Desktop/Calculate-cumulative-values-for-selected-months/m-p/2072630 

 

 

Best Regards,
Community Support Team _ Eason

 

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors