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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Puja
Helper III
Helper III

Season Help

Hello All ,

I need some help with Season Slicer.

 

I have Season and Date (Weekly Snapshots)table.

SEASON
M19
S19
M20
S20
M21
S21
M22
S22

Season range :

If it is M  Jan  -July

If it is S April -March

If user selects M22, then the dates should be Jan thru July of same year(2022).

If user selects S22 then the dates shuld be Appril 2021 thru March 2022.

 

Can some one help with this please.

TIA

 

     

 

 

 

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Puja ,

 

You can modify it to the following dax:

When M is selected, the minimum value from January to July of the Season Year is displayed.

When S is selected, the March of Season Year -1 to the April minimum of Season Year are displayed.

Flag =
VAR _select =
    SELECTEDVALUE ( 'Season Table'[Season] )
VAR _year =
    VALUE ( "20" & "" & RIGHT ( _select, 2 ) )
VAR _code =
    MAXX (
        FILTER ( ALL ( 'Season Table' ), 'Season Table'[Season] = _select ),
        [Code]
    )
VAR _MJulyfirst =
    MINX (
        FILTER (
            ALL ( 'Date table' ),
            YEAR ( 'Date table'[Date] ) = _year
                && MONTH ( 'Date table'[Date] ) = 7
        ),
        [Date]
    )
VAR _SMarchfirst =
    MINX (
        FILTER (
            ALL ( 'Date table' ),
            YEAR ( 'Date table'[Date] ) = _year
                && MONTH ( 'Date table'[Date] ) = 3
        ),
        [Date]
    )
VAR _Smindate =
    DATE ( _year - 1, 4, 1 )
RETURN
    SWITCH (
        TRUE (),
        _code = "M"
            && MAX ( 'Date table'[Date] ) >= DATE ( _year, 1, 1 )
            && MAX ( 'Date table'[Date] ) <= _MJulyfirst, 1,
        _code = "S"
            && MAX ( 'Date table'[Date] ) >= _Smindate
            && MAX ( 'Date table'[Date] ) <= _SMarchfirst, 1,
        0
    )

 

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

9 REPLIES 9
v-yangliu-msft
Community Support
Community Support

Hi  @Puja ,

 

You can modify it to the following dax:

When M is selected, the minimum value from January to July of the Season Year is displayed.

When S is selected, the March of Season Year -1 to the April minimum of Season Year are displayed.

Flag =
VAR _select =
    SELECTEDVALUE ( 'Season Table'[Season] )
VAR _year =
    VALUE ( "20" & "" & RIGHT ( _select, 2 ) )
VAR _code =
    MAXX (
        FILTER ( ALL ( 'Season Table' ), 'Season Table'[Season] = _select ),
        [Code]
    )
VAR _MJulyfirst =
    MINX (
        FILTER (
            ALL ( 'Date table' ),
            YEAR ( 'Date table'[Date] ) = _year
                && MONTH ( 'Date table'[Date] ) = 7
        ),
        [Date]
    )
VAR _SMarchfirst =
    MINX (
        FILTER (
            ALL ( 'Date table' ),
            YEAR ( 'Date table'[Date] ) = _year
                && MONTH ( 'Date table'[Date] ) = 3
        ),
        [Date]
    )
VAR _Smindate =
    DATE ( _year - 1, 4, 1 )
RETURN
    SWITCH (
        TRUE (),
        _code = "M"
            && MAX ( 'Date table'[Date] ) >= DATE ( _year, 1, 1 )
            && MAX ( 'Date table'[Date] ) <= _MJulyfirst, 1,
        _code = "S"
            && MAX ( 'Date table'[Date] ) >= _Smindate
            && MAX ( 'Date table'[Date] ) <= _SMarchfirst, 1,
        0
    )

 

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @v-yangliu-msft ,

I just noticed one limitation,

When I select S23, should show , 2022 April until 2023 March.

But I see blanks. Any thoughts ?

Puja_0-1676536374526.png

 

Perfect 🙂

 

Thank you so much @v-yangliu-msft  

v-yangliu-msft
Community Support
Community Support

Hi  @Puja ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _select=SELECTEDVALUE('Season Table'[Season])
var _code=MAXX(FILTER(ALL('Season Table'),'Season Table'[Season]=_select),[Code])
var _MJulyfirst=MINX(FILTER(ALL('Date table'),YEAR('Date table'[Date])=2022&&MONTH('Date table'[Date])=7),[Date])
var _SMarchfirst=MINX(FILTER(ALL('Date table'),YEAR('Date table'[Date])=2022&&MONTH('Date table'[Date])=3),[Date])
return
SWITCH(
    TRUE(),
    _code="M"&&MAX('Date table'[Date])>=DATE(2022,1,1)&&MAX('Date table'[Date])<=_MJulyfirst,1,
    _code="S"&&MAX('Date table'[Date])>=DATE(2021,4,1)&&MAX('Date table'[Date])<=_SMarchfirst,1,0)

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1676422866536.png

3. Result:

M22:

vyangliumsft_1-1676422866540.png

S22:

vyangliumsft_2-1676422866543.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @v-yangliu-msft  Thank you somuch.

This looks promising solution.

Can we make it dynamic for other seasons as well ?

Date range is same for M and S types.

If user selects M type, then the dates should be Jan thru July (min date) of same year.

If user selects S type then the dates shuld be Appril thru March(min date) .

 

Note: season number represents year.

ex: M21 = YEAR 2021

     S13 = YEAR 2013

Thanks again.

Puja

 

 

 

 

 

Puja
Helper III
Helper III

@v-yangliu-msft 

Could you help me with this req . 🙂

 

TIA

Can you share sample data and sample output in table format? 

amitchandak
Super User
Super User

@Puja , You have map these season with you date table. Date table should have column for that range.

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

@amitchandak  sorry this wont work. 

If I select season , I see previous years data as well.

 

Thanks

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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