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
pajero
Regular Visitor

subtotal each month cumulative

Hi all,

I am looking for a function that allows me to make a total in the table per column (month). Next month, the number from last month must be added.

Any tips?
tnx

 

pajero_2-1661345423933.png

ending up like this but without the manual work 🤠

 

pajero_3-1661345504231.png

 

 

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @pajero ,

Here are the steps you can follow:

1. Create calculated column.

Year_Month =
YEAR('Table'[handover date])&"-"&FORMAT('Table'[handover date],"mm")
Month =
MONTH('Table'[handover date])

2. In Power query. Add Column – Index Column – From 1.

vyangliumsft_0-1661828242094.png

vyangliumsft_1-1661828242099.png

3. Create measure.

Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[loc_site_category]=MAX('Table'[loc_site_category])&&
'Table'[loc_site_type]=MAX('Table'[loc_site_type])&&'Table'[Year_Month]=MAX('Table'[Year_Month]))
,[loc_name])
Measure 2 =
IF(  MAX('Table'[Index])=MINX(FILTER(ALL('Table'),'Table'[loc_site_category]=MAX('Table'[loc_site_category])&&
'Table'[loc_site_type]=MAX('Table'[loc_site_type])&&'Table'[Year_Month]=MAX('Table'[Year_Month])),[Index]),[Measure],0)
Measure 3 =
SUMX(FILTER(ALLSELECTED('Table'),'Table'[loc_site_category]=MAX('Table'[loc_site_category])&&'Table'[loc_site_type]=MAX('Table'[loc_site_type])
&&'Table'[handover date]<=MAX('Table'[handover date])),[Measure 2])

4. Result:

vyangliumsft_2-1661828242101.png

 

If you need pbix, please click here.

subtotal each month cumulative.pbix

 

Best Regards,

Liu Yang

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

View solution in original post

6 REPLIES 6
v-yangliu-msft
Community Support
Community Support

Hi  @pajero ,

Here are the steps you can follow:

1. Create calculated column.

Year_Month =
YEAR('Table'[handover date])&"-"&FORMAT('Table'[handover date],"mm")
Month =
MONTH('Table'[handover date])

2. In Power query. Add Column – Index Column – From 1.

vyangliumsft_0-1661828242094.png

vyangliumsft_1-1661828242099.png

3. Create measure.

Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[loc_site_category]=MAX('Table'[loc_site_category])&&
'Table'[loc_site_type]=MAX('Table'[loc_site_type])&&'Table'[Year_Month]=MAX('Table'[Year_Month]))
,[loc_name])
Measure 2 =
IF(  MAX('Table'[Index])=MINX(FILTER(ALL('Table'),'Table'[loc_site_category]=MAX('Table'[loc_site_category])&&
'Table'[loc_site_type]=MAX('Table'[loc_site_type])&&'Table'[Year_Month]=MAX('Table'[Year_Month])),[Index]),[Measure],0)
Measure 3 =
SUMX(FILTER(ALLSELECTED('Table'),'Table'[loc_site_category]=MAX('Table'[loc_site_category])&&'Table'[loc_site_type]=MAX('Table'[loc_site_type])
&&'Table'[handover date]<=MAX('Table'[handover date])),[Measure 2])

4. Result:

vyangliumsft_2-1661828242101.png

 

If you need pbix, please click here.

subtotal each month cumulative.pbix

 

Best Regards,

Liu Yang

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

Greg_Deckler
Super User
Super User

@pajero Depends on your data, but the general form for a running total is something like:

Measure =
  VAR __Date = MAX('Table'[Date])
  VAR __Table = FILTER(ALLSELECTED('Table'),[Date] <= __Date)
RETURN
  SUMX(__Table,[Value])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

if you want to play this is more or less the data

 

loc_nameloc_site_categoryloc_site_typehandover date
aXXX uniIndoor19/04/2022
bXXX uniIndoor19/04/2022
cconsolidatedIndoor19/04/2022
dXXX uniIndoor19/04/2022
eAAA uniIndoor05/05/2022
fconsolidatedMacro09/05/2022
gAAA uniIndoor19/04/2022
hAAA uniIndoor05/05/2022
iAAA uniIndoor19/04/2022
jAAA uniIndoor09/03/2022
kAAA uniIndoor25/03/2022
lAAA uniIndoor05/05/2022
mAAA uniIndoor01/02/2022
nAAA uniIndoor19/04/2022
oAAA uniIndoor01/02/2022
pAAA uniIndoor25/03/2022
qAAA uniIndoor19/04/2022
rAAA uniIndoor19/04/2022
sAAA uniIndoor19/04/2022
tAAA uniIndoor19/04/2022
uAAA uniIndoor19/04/2022
vconsolidatedIndoor18/03/2022
wAAA uniIndoor19/04/2022
xAAA uniIndoor19/04/2022
yAAA uniIndoor05/05/2022
zconsolidatedMacro09/05/2022
aaconsolidatedMacro09/05/2022
bbconsolidatedMacro09/05/2022
ccconsolidatedMacro09/05/2022
ddconsolidatedMacro09/05/2022
eeconsolidatedMacro09/05/2022
ffconsolidatedMacro09/05/2022
ggconsolidatedMacro09/05/2022
hhconsolidatedMacro09/05/2022
iiconsolidatedMacro09/05/2022
jjconsolidatedMacro09/05/2022
kkconsolidatedMacro09/05/2022
llconsolidatedMacro09/05/2022
mmconsolidatedMacro09/05/2022
nnconsolidatedMacro09/05/2022
ooconsolidatedMacro09/05/2022
ppconsolidatedMacro09/05/2022
qqAAA uniIndoor25/03/2022
rrAAA uniIndoor25/03/2022
ssconsolidatedMacro09/05/2022
ttconsolidatedMacro09/05/2022
uuconsolidatedMacro09/05/2022
vvXXX uniMacro09/05/2022
wwconsolidatedMacro09/05/2022
xxconsolidatedMacro09/05/2022
yyconsolidatedMacro09/05/2022
zzconsolidatedMacro09/05/2022
aaaconsolidatedMacro09/05/2022
bbbconsolidatedMacro09/05/2022
cccAAA uniIndoor25/03/2022
dddconsolidatedMacro09/05/2022
eeeconsolidatedMacro09/05/2022
fffconsolidatedMacro09/05/2022
gggconsolidatedMacro09/05/2022
hhhconsolidatedMacro09/05/2022
iiiconsolidatedMacro09/05/2022
jjjconsolidatedMacro09/05/2022
kkkconsolidatedMacro09/05/2022
lllconsolidatedMacro09/05/2022
mmmconsolidatedMacro09/05/2022
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

 

@pajero What are you totaling?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler a count of "LOC_name" based on the handoverdate

@pajero Maybe:

Measure =
  VAR __Date = MAX('Table'[handover date])
  VAR __Table = FILTER(ALLSELECTED('Table'),[handover date] <= __Date)
RETURN
  COUNTROWS(__Table,[Value])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.