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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rachels920
Frequent Visitor

Filtered visuals show all months when using +0

I have a 13 month trends line chart and matrix, however when I attempt to include results with zero on it, the FY and Month Filters are null and void and it shows me as far back as my date table goes. I have a dates table and a previous dates table in my BI. The visuals work correctly when I use the regular MyResult calculation, but when I attempt to use the MyResult w 0 it doesn't. 


MyResult = Divide([Total Results],[Total Division])


MyResult w 0 = [MyResult]+0

Filtered Month & Year = SELECTEDVALUE(_Dates[Month & Year])


MyResult L13M = 

VAR SelectedMonth = [Filtered Month & Year]
VAR PreviousDates =
DATESINPERIOD('Previous Date'[Date],
SelectedMonth,
-13, MONTH
)
Var Result=
Calculate([MyResult w 0],
REMOVEFILTERS(_Dates),
KEEPFILTERS(PreviousDates),
USERELATIONSHIP(_Dates[Date], 'Previous Date'[Date])
)

Return
 Result

The result is returned with dates going back to July 2022 which is how far my date table goes back. If I switch to without the zero, it goes back properly to the Month & Year I have selected in the filters. Is there something somewhere I can change in one of my codes to correct this?
2 REPLIES 2
rachels920
Frequent Visitor

Its still not working 😞 

I set the relationship up a while ago, but had it set as one to many but not active. Date Relationships.png

rajendraongole1
Super User
Super User

Hi @rachels920 - Ensure the relationship between Date and Previous Date is correct and active only when needed viaUSERRELATIONSHIP. Filtered Month & Year: Verify that correctly reflects the month and year you're filtering on. If this is not working as expected, you might want to inspect how this measure is defined.

 

MyResult L13M =
VAR SelectedMonth = [Filtered Month & Year]
VAR PreviousDates =
DATESINPERIOD(
'Previous Date'[Date],
SelectedMonth,
-13,
MONTH
)
VAR Result =
CALCULATE(
[MyResult], // Use the original MyResult calculation
REMOVEFILTERS(_Dates), // Remove filters from the main date table
KEEPFILTERS(PreviousDates), // Apply 13-month date filter
USERELATIONSHIP(_Dates[Date], 'Previous Date'[Date])
)

-- Include zero for missing values but respect the date filter
RETURN IF(NOT(ISBLANK(Result)), Result, 0)

 

Hope it helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.