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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
MarkusEng1998
Resolver II
Resolver II

TotalYTD Year_End_Date variable causes an error

I have measures that count year to date values for issues by status.

I use these measure as values for a stacked area graph.

Running Totals.jpg

 

These measure work when I hard code the Year_End_Date, e.g. "4-30"

 

_AMZLissuesAnswered = Calculate(TOTALYTD(DISTINCTCOUNTNOBLANK('issues_issues'[issue_id]),'issues_issues'[updated_at].[Date], "4-30"), 'issues_issues'[status] = "answered")

 

but I get the error A function 'Placeholder' has been used in a True/False expression...

when I replace it with a variable.

 

_CurrentDay = FORMAT(NOW(), "m-dd")

 

What am I missing in my variable _CurrentDay to work in the TotalYTD DAX function?

 

1 ACCEPTED SOLUTION
MarkusEng1998
Resolver II
Resolver II

I solved this through a different approach.

Instead of creating a measure for each status type with the TotalYTD function, I created a single measure for the status, and used status for the legend.

 

 

_Status2022 = 
             VAR MaxDate = MAX('issues_issues'[updated_at].[Date])
             RETURN
             CALCULATE(COUNT('issues_issues'[issue_id]),
                     DATESBETWEEN('issues_issues'[updated_at].[Date], "1-1-2022", MaxDate)
             )

 

In addition, the previous method with TotalYTD was also counting issues in previous years. The solution filters the count to a specific year now.

 

Running Totals 2.jpg

View solution in original post

1 REPLY 1
MarkusEng1998
Resolver II
Resolver II

I solved this through a different approach.

Instead of creating a measure for each status type with the TotalYTD function, I created a single measure for the status, and used status for the legend.

 

 

_Status2022 = 
             VAR MaxDate = MAX('issues_issues'[updated_at].[Date])
             RETURN
             CALCULATE(COUNT('issues_issues'[issue_id]),
                     DATESBETWEEN('issues_issues'[updated_at].[Date], "1-1-2022", MaxDate)
             )

 

In addition, the previous method with TotalYTD was also counting issues in previous years. The solution filters the count to a specific year now.

 

Running Totals 2.jpg

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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