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
Cado_one
Resolver III
Resolver III

Cumulative value of a measure

Hello,

 

I face an issue with a measure (called PreviewCumul).

This is the context :

Cado_one_0-1657522072931.png

The [Preview] is a measure corresponding to the [Realized] column if MONTH([Date]) <= 2, else [Provisional] column

Preview = 
VAR MonthCount = 2
RETURN
IF(
    MAX(Dates[MoisNum]) <= MonthCount,
    SUMX(
        'Table1',
        Table1[Realized]
    ),
    SUMX(
        'Table2',
        Table2[Provisional]
    )
)

My problem then concerns the [PreviewCumul] measure that does the running total of [Preview]

PreviewCumul =
CALCULATE(
	[Preview],
	FILTER(
		CALCULATETABLE(
			SUMMARIZE('Dates', 'Dates'[AnnéeMoisTri], 'Dates'[engDate]),
			ALLSELECTED('Dates')
		),
		ISONORAFTER(
			'Dates'[AnnéeMoisTri], MAX('Dates'[AnnéeMoisTri]), DESC,
			'Dates'[engDate], MAX('Dates'[engDate]), DESC
		)
	)
)

As we can see in the table screenshot above, the problem is that as from month number 3 it sums the values of [provisional] only from the beginning of the year instead of summing [Preview] values.

 

Does anyone have an idea of a clean way to solve it ?

Thanks in advance.

Best regards,

Cado

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Cado_one , You need to try measure like

 

calculate(Sumx(Values('Date'[Month Year]), [Preview]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

 

 

or


calculate(Sumx(Values('Date'[Month Year]), [Preview]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Cado_one , You need to try measure like

 

calculate(Sumx(Values('Date'[Month Year]), [Preview]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

 

 

or


calculate(Sumx(Values('Date'[Month Year]), [Preview]),filter(allselected('Date'),'Date'[date] <=max('Date'[date])))

Hi @amitchandak 

 

The second one is fine, thanks !

 

Cado

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.