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
Tihannah
Resolver I
Resolver I

Filtering based on Date Selection

Let's say I have a load of fruit and the dates we stopped stocking them in addition to current in a Fruit Dimension table.

Apples -removed 1/15/22

Oranges - removed 3/5/22

Grapes - removed 4/11/22

Bananas - Active

Pears - Active

 

I currently have a filter on all removed items, but want those items to show up if the month selected is equal to or less than the date they were removed from inventory. I do not want them to show in the months following the removal date, but if I used the Removed filter, I lose everything historically.  How can I write a dax or create a filter that only removes them the month AFTER the month of stock date ending? 

i.e. If I select January 2022, I see my inventory of apples, but if I select February 2022, I would not see the apples.

 

1 ACCEPTED SOLUTION
Tihannah
Resolver I
Resolver I

I was able to resolve this adding a Max Date for the Month of Date Removed and then a Flag if Date Removed was >= the Max Date. I then filtered on the Flag. Thanks.

View solution in original post

4 REPLIES 4
Tihannah
Resolver I
Resolver I

I was able to resolve this adding a Max Date for the Month of Date Removed and then a Flag if Date Removed was >= the Max Date. I then filtered on the Flag. Thanks.

danextian
Super User
Super User

Hi @Tihannah ,

 

I'd use a different Dates table to achieve this then create this measure to count the rows of Date Removed with which are either blank or less than or equal the currently selected period.

Is Active = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    ALL ( Dates ),
    FILTER (
        ALL ( 'Table'[Date Removed] ),
        'Table'[Date Removed] <= MAX ( Dates[Date] )
            || 'Table'[Date Removed] = BLANK ()
    )
)

Please refer to this PBIX for your reference -https://drive.google.com/file/d/1lLJC0_SJMfDKYqT-q3DwFVkyTmx8aq_e/view?usp=sharing 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

I tried changing this = 

'Table'[Date Removed] <= MAX ( Dates[Date]

to >=, but then when I select the month that they were removed, i.e. January - the apples disappear. 

This appears to be operating backwards to my goal. When I select January, the items removed in March and April do not show, and when I select April, the item from January is still there? I will be showing inventory counts, and if Apples were removed in January, then I do not want them to show on the list in April.

 

 

Sample.PNG

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.