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
    • Microsoft 365 + Power BI
    • Dynamics 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
    • Events
    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
    • DAX: Get all dates between the Start and End date

    DAX: Get all dates between the Start and End date

    08-18-2022 05:57 AM

    Super User amitchandak
    Super User
    1185 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
    • Report Inappropriate Content

    DAX: Get all dates between the Start and End date

    ‎08-18-2022 05:57 AM

    Problem Statement: Data has been provided with the date range in each row. Data need to be distributed or expanded for all the dates in the range.

    Power BI(176).png

     


    A new solution is needed using the DAX.
    The old DAX solution: here, Power Query Solution- here


    In DAX, we will use Generate along with Calendar to create a table of the dates between two dates. In the same way, we create a calendar. But for each row and expand into multiple rows using Generate.

     

    We have table like

    amitchandak_0-1660827330532.png

     

     

    Code for the new table with all dates between the start and end date

    Expanded = GENERATE(Data,CALENDAR(Data[Start date],Data[End date]))

     

    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



    Microsoft Power BI Learning Resources, 2023 !!
    Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
    Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
    Formatted Profit and Loss Statement with empty lines
    Power BI DAX Expand Between Range.pbix
    Labels:
    • Labels:
    • Financial
    • Mathematical
    • Time Intelligence
    Message 1 of 3
    1,185 Views
    1
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    Maha1
    Maha1 Helper I
    Helper I
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎01-11-2023 11:30 PM

    Hi @amitchandak ,

     

    Why I cannot select the start date column from the table I selected. I used the below formula and columns selected where gray:

    Table = GENERATE(Population,CALENDAR(Population[Start date],Population[End date]))
    Message 3 of 3
    563 Views
    0
    Reply
    skolathu79
    skolathu79
    New Member
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎11-23-2022 07:55 AM

    Thanks Amit, for sharing this solution. how do we get startdateofmonth instead of all dates within a range.

    Message 2 of 3
    840 Views
    0
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • 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

    © 2023 Microsoft

    Follow Power BI

    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks
    California Consumer Privacy Act (CCPA) Opt-Out Icon Your California Privacy Choices