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
ronaldbalza2023
Continued Contributor
Continued Contributor

Stopping after last value on CUMULATIVE measure

Hi everyone, I am having a hard time figuring out how to do this. 

 

Question: How can I remove empty values on the cumulative measure?

Here's my cumulative measure

Total Sales - Journals (Cummulative) = 
CALCULATE( 
	[Total Sales (Journals)], 
	FILTER(
		ALLSELECTED( Dates),
		Dates[Date] <= MAX( Dates[Date])
	)
)

 

Total Sales (Journals) = 
CALCULATE (
    0 - SUM ( 'Journals'[Net Amount FX] ),
    FILTER (
        'Accounts',
        Accounts[Account Type] = "Sales"
            || Accounts[Account Type] = "Revenue"
    ),
    USERELATIONSHIP ( Journals[ID], 'Tracking Category CONNECTIONS'[ID] )
)
1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@ronaldbalza2023  What do you mean by 'how do you remove empty values? 

Assuming you want to stop the line before it flattens out? 

 

You can do this with an if statement and define the LastDate, similar to this measure I've used in the COVID NZ report https://excelwithallison.blogspot.com/search/label/COVID19 : 

 

Lockdown August 2021 AKL Level =
VAR _StartDate = [Lockdown August 2021 Start Date]
VAR _LastDate = CALCULATE(MAX('NZ Key Dates'[Date]), LASTDATE('NZ Key Dates'[Date]))
VAR _Duration = MAX('Days In Lockdown'[Days In Lockdown])
VAR _CaseDate = _StartDate + _Duration
VAR _KeyDate = MAXX(FILTER('NZ Key Dates', 'NZ Key Dates'[Date]<= _CaseDate), 'NZ Key Dates'[Date])
RETURN
IF( _CaseDate < _LastDate,
SUMX(
FILTER('NZ Key Dates', 'NZ Key Dates'[Date] = _KeyDate)
, 'NZ Key Dates'[AKL Level Number]
)
)
 
For your data this might look something like: 
 
Total Sales - Journals (Cummulative) =
VAR _LastDate = CALCULATE(MAX('Journals'[Date]), LASTDATE('Journals'[Date]) )
VAR _VisualDate = MAX(Dates[Date])
RETURN
IF( _VisualDate <= _LastDate,
CALCULATE(
[Total Sales (Journals)],
FILTER(
ALLSELECTED( Dates),
Dates[Date] <= MAX( Dates[Date])
)
)
)

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
AllisonKennedy
Super User
Super User

@ronaldbalza2023  What do you mean by 'how do you remove empty values? 

Assuming you want to stop the line before it flattens out? 

 

You can do this with an if statement and define the LastDate, similar to this measure I've used in the COVID NZ report https://excelwithallison.blogspot.com/search/label/COVID19 : 

 

Lockdown August 2021 AKL Level =
VAR _StartDate = [Lockdown August 2021 Start Date]
VAR _LastDate = CALCULATE(MAX('NZ Key Dates'[Date]), LASTDATE('NZ Key Dates'[Date]))
VAR _Duration = MAX('Days In Lockdown'[Days In Lockdown])
VAR _CaseDate = _StartDate + _Duration
VAR _KeyDate = MAXX(FILTER('NZ Key Dates', 'NZ Key Dates'[Date]<= _CaseDate), 'NZ Key Dates'[Date])
RETURN
IF( _CaseDate < _LastDate,
SUMX(
FILTER('NZ Key Dates', 'NZ Key Dates'[Date] = _KeyDate)
, 'NZ Key Dates'[AKL Level Number]
)
)
 
For your data this might look something like: 
 
Total Sales - Journals (Cummulative) =
VAR _LastDate = CALCULATE(MAX('Journals'[Date]), LASTDATE('Journals'[Date]) )
VAR _VisualDate = MAX(Dates[Date])
RETURN
IF( _VisualDate <= _LastDate,
CALCULATE(
[Total Sales (Journals)],
FILTER(
ALLSELECTED( Dates),
Dates[Date] <= MAX( Dates[Date])
)
)
)

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy , thanks Allison worked like charm! 

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.