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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Show previous values for the selected slicer value

Hello All

I need some help with the following satiation

I have to show the previous months values when I select a month from the slicer (the month order is from July 2019 to June 2020)

If I select July I need to see just the July value

or

If I select any other month like November I have to show from July to November

or 

If  I select any other month like January I have to show from July to January

 

My table:- 
i have a table

 

METRIC_CONFIG_IDYearMonthMETRIC_VALUE_MTM
4012019July493
4012019August484
4012019September634
4012019October409
4012019November400
4012019December304
4012020January445
4012020February189
4012020March100
4012020April 
4012020May 
4012020June 
4022019July219
4022019August323
4022019September404
4022019October363
4022019November665
4022019December321
4022020January370
4022020February215
4022020March0
4022020April 
4022020May 
4022020June 
4032019July891
4032019August1559
4032019September959
4032019October1623
4032019November1479
4032019December1933
4032020January1263
4032020February1615

 

and i have the month as a slicer as shown below 

month slicermonth slicer

the issue i am having is when i select a month in the slicer i should display all the previous months values all
Example :-
when i select a month let’s say July i able to get the line graph with only July month value which is right, because the month in my table starts with July (July 2019 to June 2020)

 

line graphline graph

My Issue:----- 

but when i select any other month, lets take November i should display from July to November

(not just November as shown in the image below )

 

exapmle.PNG

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

I created a sample. Please have a try to check if it is what you want.

Measure = 
VAR SelectedMonth =
    SELECTEDVALUE ( 'Month'[MonthNo.] )
VAR SelectedYear =
    IF ( SelectedMonth <= 6, 2020, 2019 )
RETURN
SWITCH(SelectedYear,
    2019,
        CALCULATE (
            SUM ( 'Table'[METRIC_VALUE_MTM] ),
            FILTER (
                'Table',
                'Table'[Year] = SelectedYear
                    && 'Table'[MonthNo.] <= SelectedMonth
            )
        ),
        2020,
            CALCULATE (
                SUM ( 'Table'[METRIC_VALUE_MTM] ),
                FILTER (
                    'Table',
                    'Table'[Year] = SelectedYear
                        && 'Table'[MonthNo.] <= SelectedMonth
                )
            )
                + CALCULATE (
                    SUM ( 'Table'[METRIC_VALUE_MTM] ),
                    'Table'[Year] = SelectedYear - 1
                )
        )
    

1.PNG

 For more details, please download the attachment below.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi there,
Thanks for the approach,
But the data table I was shown is just an example I have multiple years of data not just 2019 and 2020
can we keep the year dynamic not just to limit that to 2019 and 2020

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.