Forum Discussion

b2wise's avatar
b2wise
Icon for Helper III rankHelper III
5 years ago

Filter Date Slicer To Only Show Months With Full Data

Hi All,

 

I have a dataset where three of my tables are excel tables that I have to update manually. I want to filter the date slicer visual (Month&Year) on the report page to only allow selections of months when the data is complete for that month.

 

In other words if the max date of any of the 3 tables is in September 2021 only allow to select up to August 2021 because the data for September isn't complete.

 

Here is an example of my three tables:

 

Temp Hours

DateHours
09/05/202136.00
10/07/201835.00
10/14/201826.00

 

Punch_Report

DATETOTAL
9/25/20211.5
9/24/20215.32
9/23/20215.82

 

Warehouse Errors: (Max of any of the date fields, if this is too hard my relationship is to 'Date of Occurence' so can just use that one)

Date of OccurenceItemDate CreatedDate ClosedLast Modified
6/19/2019 14:171-ABC6/30/2021 11:146/30/2021 12:149/30/2021 12:14
7/19/2019 0:002-CDE7/31/2019 14:408/1/2019 18:058/17/2020 13:34
10/15/2019 0:003-EFG12/18/2019 12:5412/19/2019 18:1712/19/2019 18:17

 

Date Table (Just 2 of my many columns in the date table. I use this one)

DateMonth & Year
8/3/2021Aug 2021
9/7/2021Sep 2021
10/5/2021Oct 2021

 

My dataset is already slow so I would appreciate any quick performing DAX rather than calculated columns.

 

Thanks in advance!

 

3 Replies

  • "when the data is complete for that month"

     

    How do you decide that?  Based on the presence of data for the next month?

    • b2wise's avatar
      b2wise
      Icon for Helper III rankHelper III

      lbendlin Yes, I know it's not perfect but it should work given that these tables have a new entry almost every day.

  • b2wise I tried this formula, and set a visual level filter as greater than 0 but it's not working

     

    Date Slicer Limiter =
    --Limit date slicer to previous month from latest month date
    VAR maxpunchdate =
        MAX ( Punch_Report[DATE] )
    VAR maxtemphours =
        MAX ( 'Temp Hours'[Invoice Date] )
    VAR minmonth =
        MONTH ( MIN ( maxpunchdate, maxtemphours ) )
    VAR minyear =
        YEAR ( MIN ( maxpunchdate, maxtemphours ) )
    RETURN
        CALCULATE (
            COUNTROWS ( Dates ),
            YEAR ( Dates[Date] )
                && MONTH ( Dates[Date] ) < YEAR ( minyear )
                && MONTH ( minmonth )
        )