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
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!:
The Definitive Guide to Power Query (M)

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