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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
anee123
Helper I
Helper I

Some filters don't work in DAX but works fine in visual level filter, we need this filter in DAX

Hi,

 

I have a boolean filed as shown below. This is a calculated column

 Sample1_IsSamePeriodLY = IF('Sample1_Calendar date'[Date] >= DATE(YEAR(TODAY()), 1, 1), 1 &&
IF('Sample1_Calendar date'[Date] <= TODAY()-1, 1, 0))

 

I want this filter to be part of the my previous ytd calculation, however when i use this in visual or page level filters, it works fine and gives only true records.

 

if i use it inside dax like, it does not filter the true values. The main reason behind putting this in dax is i need to calculate Variance %, if i put visual level filters for %variance, the results are wrong, I need the filter in dax so that 

the % calculation is accurate. Can you please look into it. PYTD, YTD and Variance all are measures.

 

PYTD Sample1 =
CALCULATE (
DISTINCTCOUNT(Sample1[activation_id]),SAMEPERIODLASTYEAR('Sample1_Calendar date'[Date]),
KEEPFILTERS(Sample1[paid_unpaid] ="Paid"),
KEEPFILTERS(Sample1[RealRegion_Sample1] <> "OTHER"),
KEEPFILTERS(Sample1[RealRegion_Sample1] <> BLANK())
('Sample1_Calendar date'[Sample1_IsSamePeriodLY] = TRUE())
)

 

 

YTD Sample1 =
CALCULATE (
DISTINCTCOUNT(Sample1[activation_id]),
KEEPFILTERS('Saample1_Calendar date'[Date]>= date(2021,01,01)),
keepfilters('Sample1_Calendar date'[Date] <= date(2021,12,31)),
KEEPFILTERS(Sample1[paid_unpaid] = "Paid"),
KEEPFILTERS(Sample1RealRegion] <> "ABC"),
KEEPFILTERS(Sample1[RealRegion]<> "OTHER"),
KEEPFILTERS(Sample1[RealRegion]<> BLANK()))

 

%Variance_Sample1 =
VAR __BASELINE_VALUE = [PYTD Sample1]
VAR __VALUE_TO_COMPARE = [YTD Sample1]
RETURN
DIVIDE(__VALUE_TO_COMPARE - __BASELINE_VALUE, __BASELINE_VALUE)

3 REPLIES 3
lbendlin
Super User
Super User

KEEPFILTERS() does not work the same way a visual, page or report filter works.  Using KEEPFILTERS in DAX - SQLBI

 

Show the expected outcome.

Hi,

 

Please find the pbix attached and the desired output is shown, I have used visual level filters and I am geeting desired % variance, but I want that the calc column(Sample1_IsSamePeriodLY)  inside DAX? is there a way?

 

Sample1_IsSamePeriodLY = IF('Sample1_Calendar'[Date]>= DATE(YEAR(TODAY()), 1, 1), 1 &&
                                     IF('Sample1_Calendar'[Date] <= TODAY()-1, 1, 0))

 

https://drive.google.com/file/d/1q2NjptMzZlFOU1DtDIRGZ0fHjQl97-X1/view?usp=sharing

@lbendlin @amitchandak  did you get a chance to look at my above reply.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.