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

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

Reply
Yubo
Helper I
Helper I

DATEADD measure as a filter is not working.

Hello,

I tried to use this formula as a filter to get report for 2 days. 

 

Filter = if(

    SELECTEDVALUE(Final[Start Date])>=SELECTEDVALUE(Final[Report RunDate]) &&

    SELECTEDVALUE(Final[Start Date])<= DATEADD(Final[Report RunDate], 2,day) ,1,0   )

even if  I can see some [Start Date] there between Report RunDate and Report RunDate+2 days, it shows all 0.

Please help.

Many thanks, 🙂

 

 

8 REPLIES 8
amitchandak
Super User
Super User

@Yubo , Where are you using this. If it is measure use something like this

Date Period =
var _max =maxx(allselected(date),date[date])
var _min =minx(allselected(date,date[date]))-2

return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date),date[date]=_max || date[date]=_min))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amitchandak,

 

  I use it to filter the report, I put it in the report for test and will put it as Visual-level filter =1.

Please see the attachment. May8.png

Many thanks,

 

mahoneypat
Microsoft Employee
Microsoft Employee

Dateadd() returns a table of Date (even if just 1), so not sure you would get True in this application.  You could just try Final[ReportRunDate] + 2 instead.  You are going for a table visual with Dates and 1 or 0s?

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi Pat,

 

It is not working. +2

Thanks for reply. 🙂

mahoneypat
Microsoft Employee
Microsoft Employee

Can you provide some sample data and desired output (is this measure going in a card or a table?)?  Hard to tell what you are trying to accomplish.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi Pat,

 

I don't want to put it in the report, will use it as visual-level filter to have the report only including those days records,

for example, I want the report only showing the data=06/05.2020. 

May81.png

 

Many thanks,

 

Anonymous
Not applicable

Hi @Yubo,

If you want to achieve a specific filter range instead of directly filter on your records, please use unrelated table fields as the source of the filter.

 

Measure =
VAR currDate =
    MAX ( Final[Start Date] )
RETURN
    IF (
        currDate
            IN CALENDAR (
                MINX ( ALLSELECTED ( 'Calendar'[Date] ), [Date] ),
                MAXX ( ALLSELECTED ( 'Calendar'[Date] ), [Date] ) + 2
            ),
        1,
        0
    )

 

Notice: 'Calendar' is a date table that not related to raw table records.

Regards,

Xiaoxin Sheng

Hi Xiaoxin,

I set up releationship bwtween final table and calendar table, but as you said, it is still not working, I tried the code, the dates I got are not what I want, I may study your coding later.I appreciate it.

Many thanks for your help! 🙂

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors