cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dBrand
Regular Visitor

Trying to replace a Date filter in a measure, based of the date filter

I have a Date table and a Fact Table. I have a Quarter and Year field in my Date table. I have a Filter on the page for the Quarter. I would like to calculate the total hours form the Fact table for the Year, based on the Quarter selected in the Filter. I try using:

Calulcate(Sum(fact[hours]), Date[Year]), but it always returns the hours for the Quarter? Not sure how to tell it to replace the Quarter filter with the Year, based onthe Quarter selected. Any help would be appreciated! Thanks you.

2 ACCEPTED SOLUTIONS

My Date table has a Quarter field in format 2020Q1, 2020Q2,...

the Year field is the 4-digit year. 

View solution in original post

I finally figured this out. Maybe htis will help others. Here is what I came up with (Sheet1 is the data set, Dates is my Date Table):

 

Total Amt for Year =
VAR HoldFilter = SELECTEDVALUE(Dates[Year Quarter])
VAR HoldYear = LEFT(HoldFilter, 4)
RETURN
CALCULATE(Sumx(Sheet1,Sheet1[Amt]),REMOVEFILTERS(Dates[Year Quarter]), Dates[Year]=Value(HoldYear))

View solution in original post

4 REPLIES 4
dBrand
Regular Visitor

Could really use help. Still unable to make this work. Please. Thanks,

Greg_Deckler
Super User
Super User

@dBrand What does your data look like? Is your quarter field something like Q12021, Q22021 or just Q1, Q2, etc.?


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop!
Microsoft Hates Greg's Quick Measures
Check out my latest book!

I finally figured this out. Maybe htis will help others. Here is what I came up with (Sheet1 is the data set, Dates is my Date Table):

 

Total Amt for Year =
VAR HoldFilter = SELECTEDVALUE(Dates[Year Quarter])
VAR HoldYear = LEFT(HoldFilter, 4)
RETURN
CALCULATE(Sumx(Sheet1,Sheet1[Amt]),REMOVEFILTERS(Dates[Year Quarter]), Dates[Year]=Value(HoldYear))

View solution in original post

My Date table has a Quarter field in format 2020Q1, 2020Q2,...

the Year field is the 4-digit year. 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!