skip to main content
Power BI
    • What is Power BI
    • Why Power BI
    • Customer stories
    • Data visuals
    • Security
    • Power BI Desktop
    • Power BI Pro
    • Power BI Premium
    • Power BI Mobile
    • Power BI Embedded
    • Power BI Report Server
  • Pricing
    • Azure + Power BI
    • Office 365 + Power BI
      • Energy
      • Healthcare
      • Manufacturing
      • Media
      • Retail
    • For analysts
    • For IT
      • Overview
      • Embedded analytics
      • Power BI visuals
      • Automation
      • Documentation
      • Community
    • Overview
    • Find consulting services
    • Partner showcase
    • Find a partner
    • Become a partner
    • Instructor-led training
    • Getting started
      • Overview
      • Online workshops
      • Self-guided learning
      • Webinars
      • Documentation
      • Roadmap
      • Overview
      • Issues
      • Give feedback
    • Blog
    • Business intelligence topics
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • Events
    • User groups
    • Community blog
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Galleries
    • Community Connections & How-To Videos
    • COVID-19 Data Stories Gallery
    • Themes Gallery
    • Data Stories Gallery
    • R Script Showcase
    • Webinars and Video Gallery
    • Quick Measures Gallery
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power BI Community
    • Galleries
    • Quick Measures Gallery
    • Cheat Sheet - Power BI Time Intelligence Formulas ...

    Cheat Sheet - Power BI Time Intelligence Formulas Using Today

    05-22-2022 04:15 AM - last edited 05-22-2022 04:21 AM

    Super User amitchandak
    Super User
    324 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    amitchandak
    Super User amitchandak
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Email to a Friend
    • Report Inappropriate Content

    Cheat Sheet - Power BI Time Intelligence Formulas Using Today

    ‎05-22-2022 04:15 AM

    Power BI(94).png

     

     Power BI Time Intelligence Formulas Using Today

    Problem Statement:

    The user does want to have a date slicer or filter. Also, the user does not want to control the measures based on the last date of the calendar. Formulas should use today's date and provide Today, yesterday, WTD, MTD, QTD, YTD sales

     

    For the date table, you can refer to my blog. These formulas do not use all to remove filters on the date table; for example filters (all('Date'), <filter code>), because the assumption is no date is selected. Otherwise, you have to use all on date

     

    Day Level Formulas using Today

     

    Today = CALCULATE([Net], FILTER('Date','Date'[Date] = Today() ) )
    
    Yesterday = CALCULATE([Net], FILTER('Date','Date'[Date] = Today()-1 ) )
    
    Same day Last week Today= CALCULATE([Net], FILTER('Date','Date'[Date] = Today()-7 ) ) 
    
    Month Start Date Today = CALCULATE([Net], FILTER('Date','Date'[Date] = Eomonth(Today(),-1)+1 ) )
    
    Month End Date Today = CALCULATE([Net], FILTER('Date','Date'[Date] = Eomonth(Today(),0) ) )
    
    Last Month End Date Today = CALCULATE([Net], FILTER('Date','Date'[Date] = Eomonth(Today(),-1) ) )
    
    Last Month End Date Today = CALCULATE([Net], FILTER('Date','Date'[Date] = Eomonth(Today(),-1) ) )
    
    Last year same WeekDay = CALCULATE([Net], FILTER('Date','Date'[Date] = Today()-364 ) )
    
    Last year same date = CALCULATE([Net], FILTER('Date','Date'[Date] = date(Year(Today())-1, month(Today()), day(Today()) )))
    

     

     

    Month Level Formulas using Today

     

    MTD Today = 
    var _min = eomonth(today(),-1)+1
    var _max =  today() 
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LMTD Today= 
    var _min = eomonth(today(),-2)+1
    var _max1 = today()
    var _max = date(year(_max1),month(_max1)-1, day(_max1))
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LYMTD Today = 
    var _min = eomonth(today(),-13)+1
    var _max1 = today()
    var _max = date(year(_max1)-1,month(_max1), day(_max1))
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    MTD Yesterday = 
    var _max =  today() -1
    var _min = eomonth(_max,-1)+1
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    This Month Today = 
    var _min = eomonth(today(),-1)+1
    var _max =  eomonth(today(),0) 
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Last Month Today = 
    var _min = eomonth(today(),-2)+1
    var _max =  eomonth(today(),-1) 
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Same Month Last Year Today = 
    var _min = eomonth(today(),-13)+1
    var _max =  eomonth(today(),-12) 
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    
    First Month This year Today = 
    var _min = eomonth(today(),-1*month(Today()))+1
    var _max =  eomonth(today(),-1*month(Today())+1) 
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Last Month Last year Today = 
    var _min = eomonth(today(),-1*month(Today())-1)+1
    var _max =  eomonth(today(),-1*month(Today())) 
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    

     

     

    Quarter Level Formulas using Today

     

    QTD Today = 
    var _max = today()
    var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    QTD Yesterday = 
    var _max = today()-1
    var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LQTD Today = 
    var _max = Date(year(today()), Month(Today())-3, day(today()))
    var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LYQTD Today = 
    var _max = Date(year(today())-1, Month(Today()), day(today()))
    var _min = eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    This Qtr Today = 
    var _today = today()
    var _max = eomonth(_today, if( mod(Month(_today),3) =0,0,3-mod(Month(_today),3)))
    var _min = eomonth(_max,-3)+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Last Qtr Today = 
    var _today = today()
    var _max = eomonth(_today, -1*if( mod(Month(_today),3) =0,3,mod(Month(_today),3)))
    var _min = eomonth(_max,-3)+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Same Qtr Last Year Today = 
    var _today = today()
    var _max = eomonth(eomonth(_today, if( mod(Month(_today),3) =0,0,3-mod(Month(_today),3))),-12)
    var _min = eomonth(_max,-3)+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    First Qtr This year Today = 
    var _min = eomonth(today(),-1*month(Today()))+1
    var _max =  eomonth(_min,2) 
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Last Qtr Last year Today = 
    var _max = eomonth(today(),-1*month(Today()))
    var _min =  eomonth(_max,-3)+1 
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    

     

     

    Year Level Formulas using Today

     

    YTD Today = 
    var _min = eomonth(today(),-1*month(today()))+1
    var _max =  today() 
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    YTD Yesterday = 
    var _min = eomonth(today(),-1*month(today()))+1
    var _max =  today() -1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LYTD Today = 
    var _today = TODAY()
    var _max =  date(year(_today)-1, month(_today), day(_today))
    var _min = eomonth(_max,-1*month(_max))+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LYTD Yesterday = 
    var _today = TODAY()-1
    var _max =  date(year(_today)-1, month(_today), day(_today))
    var _min = eomonth(_max,-1*month(_max))+1
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    This year Today = 
    var _min = eomonth(today(),-1*month(today()))+1
    var _max =  eomonth(_min,11) 
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Last year Today = 
    var _max = eomonth(today(),-1*month(today()))
    var _min =  eomonth(_max,-12)+1 
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    2nd Last year Today = 
    var _max = eomonth(today(),(-1*month(today()))-12)
    var _min =  eomonth(_max,-12)+1 
    return 
    CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    

     

     

    Week Level Formulas using Today

     

    WTD Today = 
    var _min = TODAY() -WEEKDAY(TODAY(),2) +1 //Monday week start
    var _max =  today() 
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LWTD Today = 
    var _min = TODAY() -WEEKDAY(TODAY(),2) -6 //Monday week start
    var _max =  today() -7
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LYWTD Today = 
    var _max =  today() -364
    var _min = _max -WEEKDAY(_max,2) +1//Monday week start
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    WTD Yesterday = 
    var _max =  today() -1
    var _min = _max -WEEKDAY(_max,2) +1 //Monday week start
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LWTD Yesterday = 
    var _max =  today() -8
    var _min = _max -WEEKDAY(_max,2) +1 //Monday week start
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    LYWTD Yesterday = 
    var _max =  today() -364
    var _min = _max -WEEKDAY(_max,2) +1//Monday week start
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    This Week Today = 
    var _min = today() -WEEKDAY(today() ,2) +1 //Monday week start
    var _max =  _min +6
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Last Week Today = 
    var _min = today() -WEEKDAY(today() ,2) -6 //Monday week start
    var _max =  _min +6
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
    
    Last year same week Today = 
    var _today =  today() -364
    var _min = _today -WEEKDAY(_today,2) +1//Monday week start
    var _max = _min+6
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

     

     

     

    For more details refer to the Blog

     

    Click Here to access all my blogs and videos in a jiffy via an exclusive visual glossary using Power BI.
    Please like, share, and comment on these. Your suggestions on improvement, challenges, and new topics will help me explore more.

    You Can watch my Power BI Tutorial Series on My Channel, Subscribe, Like, and share



    New Power BI Features
    Datamarts: https://youtu.be/8tskWsJTEpg
    Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
    Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
    Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
    Want To Learn Power BI
    Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
    !! Subscribe to my youtube Channel !!
    Today Formula.pbix
    Labels:
    • Labels:
    • Financial
    • Mathematical
    • Time Intelligence
    Message 1 of 1
    324 Views
    0
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Automate
    • Power Virtual Agents

    • Sign in
    • Sign up

    Browse

    • Solutions
    • Partners
    • Consulting Services

    Downloads

    • Power BI Desktop
    • Power BI Mobile
    • Power BI Report Server
    • See all downloads

    Learn

    • Guided learning
    • Documentation
    • Support
    • Community
    • Give feedback
    • Webinars
    • Developers
    • Blog
    • Newsletter

    © 2022 Microsoft

    Follow Power BI

    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks