Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Value Of Previous Period

Hello Everyone, i have a pbix file which i tried to share but says doesnt support(i will share screenshot) that contains expenses table, revenues table, datetable and a sort table. https://1drv.ms/u/s!Ag9tIyk2ofNRjj9fJ_lA-8qzOsre?e=7JJxII 


i want to make a table that shows selected values of a date from a slicer and then show me the previous date,
but i use a timeline slicer that has alot of options to choose from ( day,month,year,week,quarter) 

my goal is to if i select the Day granuality, and choose for example 30 august 2022, i want to see also the previous day so 29 august 2022, 
if i choose the month granuality and select september, i want to see the previous value selected which is august.
if i choose the week granulaity, and select week 27 , i want to also see previous value which is week 26.

any help?

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Anonymous ,

    Take the data of the Revenue table as an example

    Here are the steps you can follow:

    1. Use Enter data to create a calculation table.

    2. Disconnect the DateTable and Revenue tables.

    3. Create measure.

    Flag =
    var _select=SELECTEDVALUE('Slicer_Table'[Slicer])
    var _min=MINX(ALLSELECTED('DateTable'),[Date])
    var _max=MAXX(ALLSELECTED('DateTable'),[Date])
    return
    SWITCH(
        TRUE(),   
            _select="Day"&&MAX('Revenue'[Date])>=_min-1&&MAX('Revenue'[Date])<=_min,1,
            _select="Month"&&MAX('Revenue'[Date])>EOMONTH(_min,-2)&&MAX('Revenue'[Date])<=_max,1,
            _select="Week"&&MAX('Revenue'[Date])>=_min - 7&&MAX('Revenue'[Date])<=_max,1,0
    )

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

    5. Result:

    When the date selection is D (2022.8.8) and the Slicer selection is Day, the data for two days is displayed

    When the date selection is M(9) and the Slicer selection is Month, the data from August to September is displayed

    When the date selection is W(35) and the Slicer selection is Week, the data from 34 weeks to 35 weeks are displayed

     

    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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    Take the data of the Revenue table as an example

    Here are the steps you can follow:

    1. Use Enter data to create a calculation table.

    2. Disconnect the DateTable and Revenue tables.

    3. Create measure.

    Flag =
    var _select=SELECTEDVALUE('Slicer_Table'[Slicer])
    var _min=MINX(ALLSELECTED('DateTable'),[Date])
    var _max=MAXX(ALLSELECTED('DateTable'),[Date])
    return
    SWITCH(
        TRUE(),   
            _select="Day"&&MAX('Revenue'[Date])>=_min-1&&MAX('Revenue'[Date])<=_min,1,
            _select="Month"&&MAX('Revenue'[Date])>EOMONTH(_min,-2)&&MAX('Revenue'[Date])<=_max,1,
            _select="Week"&&MAX('Revenue'[Date])>=_min - 7&&MAX('Revenue'[Date])<=_max,1,0
    )

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

    5. Result:

    When the date selection is D (2022.8.8) and the Slicer selection is Day, the data for two days is displayed

    When the date selection is M(9) and the Slicer selection is Month, the data from August to September is displayed

    When the date selection is W(35) and the Slicer selection is Week, the data from 34 weeks to 35 weeks are displayed

     

    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