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
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
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.