Forum Discussion

hejszyszki's avatar
hejszyszki
Frequent Visitor
5 years ago
Solved

Changing average using slicer

Hi! Below i have a graph, made of measure below which shows 4-w Average. (Material code has relationship with area in another table to be clear).  Structure of table is also shown below. Weeks are like from 1 to 78 (W1 - W78). What i would like to accomplish is to make slicer(with slider/zip) that shows range from W1 to last Week and once you pick certain range like W2-W8 it shows average of W2-W8. 
Does anyone have any idea how to do it? Is it even possible to do :)?

Thanks in advance!

  • Fowmy's avatar
    Fowmy
    5 years ago

    hejszyszki 

    You need to create another column in this table to extract the week number.

    WeekNumber = INT(SUBSTITUTE(Table12[WeekNum],"W",""))

    Then, you can use below measure and make sure you have slicer on the WeekNumber to select the range:

    measure =
    VAR __minweekno =
        MIN ( 'invo dos'[WeekNumber] )
    VAR __maxnweekno =
        MAX ( 'invo dos'[WeekNumber] )
    RETURN
        SUMX (
            FILTER (
                'invo dos',
                'invo dos'[SNP Plan] = "Short Supply"
                    && 'invo dos'[WeekNumber] >= __minweekno
                    && 'invo dos'[WeekNumber] <= __maxnweeknow
            ),
            'invo dos'[Value]
        )
    


    Note: If your data expands into more than one year then you will have to add (Year + weekNumber )

3 Replies

    • hejszyszki's avatar
      hejszyszki
      Frequent Visitor

      Ended up with something like this. Stuck when trying to create slicer of average of picked range.
      Thanks in advance!

      • Fowmy's avatar
        Fowmy
        Super User

        hejszyszki 

        You need to create another column in this table to extract the week number.

        WeekNumber = INT(SUBSTITUTE(Table12[WeekNum],"W",""))

        Then, you can use below measure and make sure you have slicer on the WeekNumber to select the range:

        measure =
        VAR __minweekno =
            MIN ( 'invo dos'[WeekNumber] )
        VAR __maxnweekno =
            MAX ( 'invo dos'[WeekNumber] )
        RETURN
            SUMX (
                FILTER (
                    'invo dos',
                    'invo dos'[SNP Plan] = "Short Supply"
                        && 'invo dos'[WeekNumber] >= __minweekno
                        && 'invo dos'[WeekNumber] <= __maxnweeknow
                ),
                'invo dos'[Value]
            )
        


        Note: If your data expands into more than one year then you will have to add (Year + weekNumber )