Close Menu
    Trending
    • Three OpenClaw Mistakes to Avoid and How to Fix Them
    • I Stole a Wall Street Trick to Solve a Google Trends Data Problem
    • How AI is turning the Iran conflict into theater
    • Why Your AI Search Evaluation Is Probably Wrong (And How to Fix It)
    • Machine Learning at Scale: Managing More Than One Model in Production
    • Improving AI models’ ability to explain their predictions | MIT News
    • Write C Code Without Learning C: The Magic of PythoC
    • LatentVLA: Latent Reasoning Models for Autonomous Driving
    ProfitlyAI
    • Home
    • Latest News
    • AI Technology
    • Latest AI Innovations
    • AI Tools & Technologies
    • Artificial Intelligence
    ProfitlyAI
    Home » How to Filter for Dates, Including or Excluding Future Dates, in Semantic Models
    Artificial Intelligence

    How to Filter for Dates, Including or Excluding Future Dates, in Semantic Models

    ProfitlyAIBy ProfitlyAIJanuary 4, 2026No Comments6 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Think about that we’ve three measures:

    1. Gross sales Quantity
    2. Gross sales Quantity Price range
    3. Gross sales Quantity PY

    After we take a look at a desk with these numbers, we see this (assuming that we’ve present knowledge till the tip of July 2025):

    Determine 1 – Place to begin. Discover that the Price range and the PY knowledge transcend the present knowledge, which exists solely till the tip of July 2025 (Determine by the Writer)

    Whereas the outcomes are appropriate, my customers may want two completely different views:

    1. See solely the outcomes in line with the prevailing knowledge
    2. Together with the Price range knowledge and the PY knowledge

    I’ve a number of methods to do it:

    1. Create separate Visuals with completely different filters.
    2. Create two pages for the 2 views, once more through the use of completely different filters.
    3. Inform my customers to make use of the Calendar slicer to filter the info as wanted.

    However I need to design my reviews as user-friendly as potential with out duplicating something.

    Subsequently, I need to add a Slicer so customers can select whether or not to incorporate future knowledge or solely see present knowledge.

    Create the Date Filter desk

    My Date desk consists of Index columns for various intervals: Days, Weeks, Months, Quarters, and Years.

    • The row with the present interval comprises a 0
    • Rows for previous intervals include unfavourable numbers
    • Rows for futures intervals include constructive numbers

    Let’s see the rows for a small pattern realized in SQL through the use of the DayIndex column:

    Determine 2 – Pattern rows from the Date desk (Determine by the Writer)

    Utilizing this column, I constructed a desk with a further column to function a Slicer.

    I took all rows with an Index as much as 0 and marked them as “Present Knowledge solely”.

    Then I appended (UNION) all rows from the Date desk and marked them as “Future Knowledge included”.

    Determine 3 – Full choice for the Date Filter desk (Determine by the Writer)

    I did it with SQL, however you are able to do it in Energy Question or some other language of your selection.

    Now, I imported this desk into Energy BI

    Increase the info mannequin

    After including this desk to Energy BI, I created a brand new Relationship between the brand new desk and the Date desk:

    Determine 4 – Creation of the Relationship between the brand new Date Filter and the Date desk (Determine by the Writer)

    The Cross-filter Route have to be set to Each because the column DateKey within the Date Filter desk shouldn’t be distinctive:

    Determine 5 – Relationship with the  Cross-filter path set to each (Determine by the Writer)

    Subsequently, the filter path can be Date -> Date Filter solely, which won’t work.

    I need to filter the Date desk by the Date Filter desk. Subsequently, I need to set the filter path to “Each”.

    Outcome

    Subsequent, I added a Slicer to the report:

    Determine 6 – The brand new Slicer set a Tile for the DateFilter column (Determine by the Writer)

    After all of the preparation, the Slicer permits the choice of the info as wanted:

    Determine 7 – No future numbers are proven when “Present Knowledge solely” is chosen (Determine by the Writer)
    Determine 8 – All knowledge is proven when “Future Knowledge included” is chosen (Determine by the Writer)

    The customers can use this slicer to decide on which knowledge they need to see, whatever the choice within the Calendar slicer.

    Deciding on full intervals

    The instance above is sensible when the choice have to be on the day degree.

    That is helpful particularly when evaluating the present knowledge with the Price range or PY.

    Think about on the 5th or 6th day of the month. You might have just a few days of Gross sales, however you evaluate it to the Price range of the entire month. This may be deceptive.

    However what occurs when the filter have to be set to full intervals, like months or years?

    Right here, a modified question to set the DateFilter column primarily based on complete years:

    Determine 9 – Question to set the entire 12 months for the DateFilter column (Determine by the Writer)

    Now the complete 12 months is proven, when solely the present knowledge must be proven:

    Determine 10 – The entire 12 months is proven when utilizing the modified question from above (Determine by the Writer)

    You’ll be able to change the Date Filter desk in the identical technique to filter by months or different intervals.

    This may be finished very simply by filtering the rows within the Date desk for the present date.

    Conclusion

    This strategy is easy to implement and straightforward for Report shoppers to make use of.

    It avoids writing DAX code and depends solely on info within the Date desk.

    The trick is to increase the info mannequin to assist the necessities with the least effort.

    In case you don’t have the Index columns as I do, you need to use a distinct strategy to generate the Date Filter desk. For instance, use a operate to get the present date, like GETDATE() in T-SQL or Now() in different languages.

    I discovered the Index columns very helpful, not solely on this case but additionally in lots of different conditions the place the consumer requires me to filter the info by dates relative to the present date.

    This makes life simple when the “present date” shouldn’t be right this moment, however should comply with a particular logic—for instance, the earlier weekday.

    OK, you’ll be able to add relative Filters to the report. In lots of instances, they’re sufficient.

    In different instances, the Index columns give me extra flexibility.

    References

    Like in my earlier articles, I exploit the Contoso pattern dataset. You’ll be able to obtain the ContosoRetailDW Dataset free of charge from Microsoft here.

    The Contoso Knowledge can be utilized freely beneath the MIT License, as described in this document. I modified the dataset to shift the info to up to date dates.



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleOptimizing Data Transfer in AI/ML Workloads
    Next Article Prompt Engineering vs RAG for Editing Resumes
    ProfitlyAI
    • Website

    Related Posts

    Artificial Intelligence

    Three OpenClaw Mistakes to Avoid and How to Fix Them

    March 9, 2026
    Artificial Intelligence

    I Stole a Wall Street Trick to Solve a Google Trends Data Problem

    March 9, 2026
    Artificial Intelligence

    Why Your AI Search Evaluation Is Probably Wrong (And How to Fix It)

    March 9, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Are You Being Unfair to LLMs?

    July 11, 2025

    AI/ML for Smarter Enterprise Document Workflows

    September 8, 2025

    Animating Linear Transformations with Quiver

    June 18, 2025

    Agentic AI with NVIDIA and DataRobot

    July 2, 2025

    It’s pretty easy to get DeepSeek to talk dirty

    June 19, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    Most Popular

    Talking to Kids About AI

    May 2, 2025

    US faces crucial decision on AI chip export rules

    April 4, 2025

    Researchers teach LLMs to solve complex planning challenges | MIT News

    April 4, 2025
    Our Picks

    Three OpenClaw Mistakes to Avoid and How to Fix Them

    March 9, 2026

    I Stole a Wall Street Trick to Solve a Google Trends Data Problem

    March 9, 2026

    How AI is turning the Iran conflict into theater

    March 9, 2026
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2025 ProfitlyAI All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.