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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Ajithrjaa
Frequent Visitor

Data Filter Condition

Hi , 

I have a some quey please add some valid use casess on this scenarion.

Case : Max Year is 2024 from that I have a min date 1/4/2024 and Max Date 7/11/2024 this is the data range for Prevoius Years.
I would Like Put a one Condition Previous Years also Baesd on this dynamics Min and Max DDMM.

the MinDate and Max Date range should be a Maxdate Year. 

DateSalesYear
11/2/2022612022
7/27/2022332022
8/18/2022672022
11/24/2022942022
7/5/2022932022
1/19/2022512022
8/22/2022672022
5/31/2022692022
8/4/2022112022
8/4/2022462022
4/4/202282022
1/11/202262022
1/15/2022362022
9/23/2022632022
9/11/2022942022
11/13/2022292022
5/22/20231002023
10/26/2023782023
12/5/2023842023
7/13/202352023
7/7/2023852023
11/24/2023512023
2/7/2023142023
8/29/2023442023
5/31/2024242024
1/4/2024362024
3/9/2024432024
2/1/2024872024
7/11/202482024
2/16/2024192024


Output Like 

DateSalesYearFlag
5/31/2024242024Y
1/4/2024362024Y
3/9/2024432024Y
2/1/2024872024Y
7/11/202482024Y
2/16/2024192024Y
5/22/20231002023Y
10/26/2023782023N
12/5/2023842023N
7/13/202352023N
7/7/2023852023Y
11/24/2023512023N
2/7/2023142023Y
8/29/2023442023N




1 ACCEPTED SOLUTION
mickey64
Super User
Super User

Step 0: I use your data. (Date:yyyy/mm/dd)

mickey64_0-1722867434168.png

 

Step 1: I make a 'Calendar' table and add a relationship.

Calendar = CALENDAR(FIRSTDATE('DATA'[Date]),LASTDATE('DATA'[Date]))

mickey64_1-1722867551536.png

 

Step 2: I make a 'Sel-Cal' table and make a 'Sel-Cal' slicer.

Sel-Cal = SUMMARIZE('DATA','DATA'[Year])

mickey64_2-1722867665752.png

- Slicer -

mickey64_3-1722867715464.png

 

Step 3: I make many measures below.

M_Flag = IF(MAX('DATA'[Date])<=[M_Maxx_Date_ALL]&&MIN('DATA'[Date])>=[M_Minx_Date_ALL],"Y",IF(MAX('DATA'[Date])<=[M_Maxx_Date_Pre_ALL]&&MIN('DATA'[Date])>=[M_Minx_Date_Pre_ALL],"Y","N"))

 

M_Maxx_Date_ALL = MAXX(FILTER(ALL('DATA'),'DATA'[Year]=[M_Year_Sel]),'DATA'[Date])

 

M_Maxx_Date_Pre_ALL = MAXX(FILTER(ALL('Calendar'),(YEAR('Calendar'[Date])=[M_Year_Sel]-1)&&('Calendar'[Date]<=[M_Max_YMD_Pre])),'Calendar'[Date])

 

M_Minx_Date_ALL = MINX(FILTER(ALL('DATA'),'DATA'[Year]=[M_Year_Sel]),'DATA'[Date])

 

M_Minx_Date_Pre_ALL = MINX(FILTER(ALL('Calendar'),(YEAR('Calendar'[Date])=[M_Year_Sel]-1)&&('Calendar'[Date]>=[M_Min_YMD_Pre])),'Calendar'[Date])

 

M_Max_YMD_Pre = DATE([M_Year_Sel]-1,[M_Max_M_ALL],[M_Max_D_ALL])

 

M_Min_YMD_Pre = DATE([M_Year_Sel]-1,[M_Min_M_ALL],[M_Min_D_ALL])

 

Step 4: I make a matrix.

mickey64_4-1722867799645.png

 

View solution in original post

3 REPLIES 3
mickey64
Super User
Super User

Step 0: I use your data. (Date:yyyy/mm/dd)

mickey64_0-1722867434168.png

 

Step 1: I make a 'Calendar' table and add a relationship.

Calendar = CALENDAR(FIRSTDATE('DATA'[Date]),LASTDATE('DATA'[Date]))

mickey64_1-1722867551536.png

 

Step 2: I make a 'Sel-Cal' table and make a 'Sel-Cal' slicer.

Sel-Cal = SUMMARIZE('DATA','DATA'[Year])

mickey64_2-1722867665752.png

- Slicer -

mickey64_3-1722867715464.png

 

Step 3: I make many measures below.

M_Flag = IF(MAX('DATA'[Date])<=[M_Maxx_Date_ALL]&&MIN('DATA'[Date])>=[M_Minx_Date_ALL],"Y",IF(MAX('DATA'[Date])<=[M_Maxx_Date_Pre_ALL]&&MIN('DATA'[Date])>=[M_Minx_Date_Pre_ALL],"Y","N"))

 

M_Maxx_Date_ALL = MAXX(FILTER(ALL('DATA'),'DATA'[Year]=[M_Year_Sel]),'DATA'[Date])

 

M_Maxx_Date_Pre_ALL = MAXX(FILTER(ALL('Calendar'),(YEAR('Calendar'[Date])=[M_Year_Sel]-1)&&('Calendar'[Date]<=[M_Max_YMD_Pre])),'Calendar'[Date])

 

M_Minx_Date_ALL = MINX(FILTER(ALL('DATA'),'DATA'[Year]=[M_Year_Sel]),'DATA'[Date])

 

M_Minx_Date_Pre_ALL = MINX(FILTER(ALL('Calendar'),(YEAR('Calendar'[Date])=[M_Year_Sel]-1)&&('Calendar'[Date]>=[M_Min_YMD_Pre])),'Calendar'[Date])

 

M_Max_YMD_Pre = DATE([M_Year_Sel]-1,[M_Max_M_ALL],[M_Max_D_ALL])

 

M_Min_YMD_Pre = DATE([M_Year_Sel]-1,[M_Min_M_ALL],[M_Min_D_ALL])

 

Step 4: I make a matrix.

mickey64_4-1722867799645.png

 

Ajithrjaa
Frequent Visitor

@danextian  thanks for the Quick Response.

my Cenario which is date range Min and Max dates from the Max Year.  this data range should be a Previous Physical Year.
this give some example based on month Basic

Ajithrjaa_0-1722863278653.png

 




danextian
Super User
Super User

Hi @Ajithrjaa ,

 

I am not exactly sure what you are trying to achieve but if you want to check whether the current period (month and year) has data in the previous year (previous year and month), you can try the calculated column below:

Flag = 
VAR PreviousYearsPeriod =
    FORMAT ( EDATE ( 'Table'[Date], -12 ), "YYYYMM" )
VAR PreviousYearsValue =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER (
            ALL ( 'Table' ),
            FORMAT ( 'Table'[Date], "YYYYMM" ) = PreviousYearsPeriod
        )
    )
RETURN
    IF ( NOT ( ISBLANK ( PreviousYearsValue ) ), "Y", "N" )

danextian_0-1722862005259.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"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.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.