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
admin11
Memorable Member
Memorable Member

How to set if year and month not selected and YTD still function ?

Hi All

 

@dvl_ctaul have provide me below expression :-

YTD_FLEX = CALCULATE (
[SALES_],
DATESYTD('DATE'[Date])
)
 
which is very fleible , i can have dynamic YTD amount in any year.
My question is , when i not select any year or month , now the table display blank or error. it there a way to make it default as current yr and month ?
 
Paul
1 ACCEPTED SOLUTION
dvl_ctaul
Helper I
Helper I

Yes, try this:

 

YTD_FLEX = 
VAR cyear = SELECTEDVALUE( 'DATE'[Year], YEAR(Now()) )
RETURN
CALCULATE (
[SALES_],
DATESYTD('DATE'[Date]),
'DATE'[Year] = cyear
)

 

You will need to make sure that you have a year column in your date table to make this work. (This will only consider year, not month)

View solution in original post

1 REPLY 1
dvl_ctaul
Helper I
Helper I

Yes, try this:

 

YTD_FLEX = 
VAR cyear = SELECTEDVALUE( 'DATE'[Year], YEAR(Now()) )
RETURN
CALCULATE (
[SALES_],
DATESYTD('DATE'[Date]),
'DATE'[Year] = cyear
)

 

You will need to make sure that you have a year column in your date table to make this work. (This will only consider year, not month)

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.