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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
uscmea
Frequent Visitor

Cumulative Sum

Hi,

I have three main measures in my data model:

 

sales = DISTINCTCOUNT(Sales[Product ID])

leads = DISTINCTCOUNT(Leads[Lead ID])
conv = IF([vacation_days]<7,[sales]/[leads],0)
 
The measure I want to do the cumulative is "conv", which depends on the number of vacation days that each employee has taken in a month. If the number of days is greater than 7, "conv" is going to be equal to 0%; if not, sales/leads.
When I try to do the cumulative sum of "conv", with the following formula:
 
cum_conv =
CALCULATE (
[conv],
FILTER (
ALL( 'Calendar'),
ISONORAFTER( 'Calendar'[Month Number]
,MAX ( 'Calendar'[Month Number] ),DESC
)
))
 
Instead of obtaining 42.86% in Month Number = 2, I obtain 0%.
 
uscmea_1-1624606462592.png

 Here find attached the Power BI model. https://drive.google.com/file/d/1izQnlhw_geZtn4bfe5T-by3BB__mbwFK/view?usp=sharing

 

Thank you in advance for your help!

 

Best,
Sara

1 ACCEPTED SOLUTION

@uscmea,

 

Try this measure:

 

cum_conv = 
VAR vCurrentMonth =
    MAX ( 'Calendar'[Month Number] )
VAR vTable =
    ADDCOLUMNS ( ALLSELECTED ( 'Calendar'[Month Number] ), "@conv", [conv] )
VAR vResult =
    SUMX ( vTable, IF ( 'Calendar'[Month Number] <= vCurrentMonth, [@conv] ) )
RETURN
    vResult

 

DataInsights_0-1625868991977.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
DataInsights
Super User
Super User

@uscmea,

 

I wasn't able to access the pbix via the link. This is the basic pattern for a cumulative sum:

 

cum_conv =
CALCULATE (
    [conv],
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Month Number] <= MAX ( 'Calendar'[Month Number] )
    )
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @DataInsights,

 

Thank you very much for your answer!

 

I tried before this formula, but for some reason, it is not working.

 

I also tried SUMX = (FILTER (ALL('Calendar'),'Calendar'[Month Number] <=MAX('Calendar'[Month Number]), [conv])), but I still do not obtain the desired result.


I shared the Power BI model via Drive, let me know if you can download it from there. 

Best regards,

Sara

@uscmea,

 

Try this measure:

 

cum_conv = 
VAR vCurrentMonth =
    MAX ( 'Calendar'[Month Number] )
VAR vTable =
    ADDCOLUMNS ( ALLSELECTED ( 'Calendar'[Month Number] ), "@conv", [conv] )
VAR vResult =
    SUMX ( vTable, IF ( 'Calendar'[Month Number] <= vCurrentMonth, [@conv] ) )
RETURN
    vResult

 

DataInsights_0-1625868991977.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you very much for your help, @DataInsights !!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.