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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
netanel
Post Prodigy
Post Prodigy

Date Button

Hi All!

 

I need your help

 

I Created in my DB column in the dim date that is called "Date Button"

The column contains three categories
Yesterday
30 days back
90 days back

 

Now I try to put that column in the slicer that filters my date

The problem is the 30 days give me 29 days

and the 90 days bring me 60 days

I tried formulas and a calculated column but without success
I would appreciate your help
Attach the file

Exmple Date.pbix

 








Did I answer your question?
Mark my post as a solution!
Appreciate your Kudos!

Connect on Linkedin
linkedin.com/in/netanel-shriki
1 ACCEPTED SOLUTION

Hi All,

I found the solution
1. First open a new table

and insert that Dax code:

Date Buttons =
VAR Yesterday =ADDCOLUMNS(
        CALCULATETABLE(
            'Dim_Date',
            FILTER(Dim_Date, Dim_Date[Date] = TODAY() - 1)
        ),
        "Last X Days", " "
    )

VAR Last30Days =ADDCOLUMNS(
        CALCULATETABLE(
            'Dim_Date',
            DATESBETWEEN(
                Dim_Date[Date],
                TODAY() - 30,  // Adjust the start date to exclude today
                TODAY() - 1   // Adjust the end date to include yesterday
            )
        ),
        "Last X Days", "  "
    )

VAR Last90Days =ADDCOLUMNS(
        CALCULATETABLE(
            'Dim_Date',
            DATESBETWEEN(
                Dim_Date[Date],
                TODAY() - 90,  // Adjust the start date to exclude today
                TODAY() - 1   // Adjust the end date to include yesterday
            )
        ),
        "Last X Days", "   "
    )
    VAR Last1737Days =
    ADDCOLUMNS(
        CALCULATETABLE(
            'Dim_Date',
            DATESBETWEEN(
                Dim_Date[Date],
                TODAY() - 1737,  // Adjust the start date to exclude today
                TODAY() - 1   // Adjust the end date to include yesterday
            )
        ),
        "Last X Days", "    "
    )

RETURN UNION(Yesterday, Last30Days, Last90Days,Last1737Days)

This table will add a new dim date that collects all the buttons in one bucket
For example yesterday you got 3 rows 
yesterday
Last 30 Days 
Ans Last 90 days

2. Step two connect to your dim date
many to one and connection both side

Good luck!

 








Did I answer your question?
Mark my post as a solution!
Appreciate your Kudos!

Connect on Linkedin
linkedin.com/in/netanel-shriki

View solution in original post

5 REPLIES 5
Idrissshatila
Super User
Super User

Hello @netanel ,

 

so this is calculated wrong from the db, because when I tried filtering the table from the data view to see the rows related to last 30 days it showed 29 as you can see in the screenshot.

Idrissshatila_0-1696172968246.png

 

And when i filtered it to show the last 90 days it only filtered 60 rows

Idrissshatila_1-1696173050380.png

 

 

so you should check the calculation of this column from the database calculation because power bi is reflecting it as it was calculated.

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin
Vote for my Community Mobile App Idea 💡



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




But that's the whole idea, think about it
In SQL I bring one column
Yesterday is one  line
Last 30 Days can't register on yesterday
The last 90 Days  cannot be registered on 30 days and yesterday

Now in Power BI, I am trying to calculate a measure
That 30 days back will bring me both yesterday and the 30 days

Beyond that, you have a separate column for each date as well
Last 30 Days whit 30 rows
Last 90 Days whit 90 rows

netanel_0-1696173741429.png

 








Did I answer your question?
Mark my post as a solution!
Appreciate your Kudos!

Connect on Linkedin
linkedin.com/in/netanel-shriki

Hello @netanel ,

 

So i adjusted the last 30 days measure to the following:

 

Last 30 Days =
VAR Last30Days = MAX('Dim_Date'[ISODateName]) -30

RETURN
SWITCH(TRUE(),
'Dim_Date'[ISODateName] > Last30Days,"Last 30 days")
 

 

Idrissshatila_0-1696178394181.png

 

And the last 90 days to the following

 

Last 90 Days =
VAR Last90Days = MAX('Dim_Date'[ISODateName]) -90

RETURN
SWITCH(TRUE(),
'Dim_Date'[ISODateName] > Last90Days,"Last 90 days")
 
Idrissshatila_1-1696178550136.png

 

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin
Vote for my Community Mobile App Idea 💡

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




@Idrissshatila 

That doesn't answer my question...
I need one measure to insert in the slicer

And get 30 days for "Last 30 Days"
And 90 Days for "Last 90 Days"

and also Yesterday

netanel_0-1696227682265.png

 








Did I answer your question?
Mark my post as a solution!
Appreciate your Kudos!

Connect on Linkedin
linkedin.com/in/netanel-shriki

Hi All,

I found the solution
1. First open a new table

and insert that Dax code:

Date Buttons =
VAR Yesterday =ADDCOLUMNS(
        CALCULATETABLE(
            'Dim_Date',
            FILTER(Dim_Date, Dim_Date[Date] = TODAY() - 1)
        ),
        "Last X Days", " "
    )

VAR Last30Days =ADDCOLUMNS(
        CALCULATETABLE(
            'Dim_Date',
            DATESBETWEEN(
                Dim_Date[Date],
                TODAY() - 30,  // Adjust the start date to exclude today
                TODAY() - 1   // Adjust the end date to include yesterday
            )
        ),
        "Last X Days", "  "
    )

VAR Last90Days =ADDCOLUMNS(
        CALCULATETABLE(
            'Dim_Date',
            DATESBETWEEN(
                Dim_Date[Date],
                TODAY() - 90,  // Adjust the start date to exclude today
                TODAY() - 1   // Adjust the end date to include yesterday
            )
        ),
        "Last X Days", "   "
    )
    VAR Last1737Days =
    ADDCOLUMNS(
        CALCULATETABLE(
            'Dim_Date',
            DATESBETWEEN(
                Dim_Date[Date],
                TODAY() - 1737,  // Adjust the start date to exclude today
                TODAY() - 1   // Adjust the end date to include yesterday
            )
        ),
        "Last X Days", "    "
    )

RETURN UNION(Yesterday, Last30Days, Last90Days,Last1737Days)

This table will add a new dim date that collects all the buttons in one bucket
For example yesterday you got 3 rows 
yesterday
Last 30 Days 
Ans Last 90 days

2. Step two connect to your dim date
many to one and connection both side

Good luck!

 








Did I answer your question?
Mark my post as a solution!
Appreciate your Kudos!

Connect on Linkedin
linkedin.com/in/netanel-shriki

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.