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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
dBrand
Frequent 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
Frequent 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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

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))

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

the Year field is the 4-digit year. 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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