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

moth change

hiii
i want a line graph which needs to display past 2 months data and present month data based on the slicer selection
like if i select april my line graph should display feb march and april data
of raw sla% , m.sla% and call closed
how can i do that can some one show that

https://drive.google.com/file/d/1lTcK5CQsdl3rteKc5GLimkEmjcjPDGR7/view?usp=sharing

1 ACCEPTED SOLUTION
negi007
Community Champion
Community Champion

@greeshma I couldn't open the file as I have the previous version of Power Bi. But you can check the links below for your problem

http://sqljason.com/2018/03/display-last-n-months-selected-month-using-single-date-dimension-in-powe...

https://stackoverflow.com/questions/49146565/show-last-3-months-from-selected-month-in-power-bi

https://radacad.com/only-get-the-last-few-periods-of-data-into-power-bi-using-power-query-filtering




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



Proud to be a Super User!


Follow me on linkedin

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

1.If you want to display past 2 months data, you need to make sure that the filter values in your slicer are not related to the sample data.

1.png

 

2.Create YearMonth column for the slicer.

Table = 
ADDCOLUMNS (
    FILTER ( VALUES ( Query1[Call Closed] ), [Call Closed] <> BLANK () ),
    "Year", YEAR ( [Call Closed] ),
    "Month", MONTH ( [Call Closed] ),
    "YearMonth",YEAR([Call Closed])&"-"&FORMAT([Call Closed],"MM"
)
)

2.png

 

3.Two measures are these.

M.SLA% = 
VAR _sel =
    SELECTEDVALUE ( 'Table'[YearMonth] )
RETURN
    CALCULATE (
        IFERROR ( ( Query1[M HIT] / Query1[M.COUNT] * 100 ), 100 ),
        FILTER (
            'Query1',
             (
                 (
                    MONTH ( 'Query1'[Call Closed] ) = VALUE ( RIGHT ( _sel, 2 ) )
                        || MONTH ( 'Query1'[Call Closed] )
                            = VALUE ( RIGHT ( _sel, 2 ) ) - 1
                        || MONTH ( 'Query1'[Call Closed] )
                            = VALUE ( RIGHT ( _sel, 2 ) ) - 2
                )
                    && YEAR ( 'Query1'[Call Closed] ) = VALUE ( LEFT ( _sel, 4 ) )
                    && VALUE ( RIGHT ( _sel, 2 ) ) IN { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
            )
                || (
                    VALUE ( RIGHT ( _sel, 2 ) ) = 2
                        && (
                             (
                                YEAR ( 'Query1'[Call Closed] ) = VALUE ( LEFT ( _sel, 4 ) )
                                    && (
                                        MONTH ( 'Query1'[Call Closed] ) = VALUE ( RIGHT ( _sel, 2 ) )
                                            || MONTH ( 'Query1'[Call Closed] )
                                                = VALUE ( RIGHT ( _sel, 2 ) ) - 1
                                    )
                            )
                                || (
                                     (
                                        YEAR ( 'Query1'[Call Closed] )
                                            = VALUE ( LEFT ( _sel, 4 ) ) - 1
                                            && ( MONTH ( 'Query1'[Call Closed] ) = 12 )
                                    )
                                )
                        )
                )
                || (
                    VALUE ( RIGHT ( _sel, 2 ) ) = 1
                        && (
                             (
                                YEAR ( 'Query1'[Call Closed] ) = VALUE ( LEFT ( _sel, 4 ) )
                                    && ( MONTH ( 'Query1'[Call Closed] ) = VALUE ( RIGHT ( _sel, 2 ) ) )
                            )
                                || (
                                     (
                                        YEAR ( 'Query1'[Call Closed] )
                                            = VALUE ( LEFT ( _sel, 4 ) ) - 1
                                            && (
                                                MONTH ( 'Query1'[Call Closed] ) = 12
                                                    || MONTH ( 'Query1'[Call Closed] ) = 11
                                            )
                                    )
                                )
                        )
                )
        )
    )
RAW SLA% = 
VAR _sel =
    SELECTEDVALUE ( 'Table'[YearMonth] )
RETURN
    CALCULATE (
        IFERROR ( ( Query1[RAW HIT] / Query1[RAW COUNT] * 100 ), 100 ),
        FILTER (
            'Query1',
             (
                 (
                    MONTH ( 'Query1'[Call Closed] ) = VALUE ( RIGHT ( _sel, 2 ) )
                        || MONTH ( 'Query1'[Call Closed] )
                            = VALUE ( RIGHT ( _sel, 2 ) ) - 1
                        || MONTH ( 'Query1'[Call Closed] )
                            = VALUE ( RIGHT ( _sel, 2 ) ) - 2
                )
                    && YEAR ( 'Query1'[Call Closed] ) = VALUE ( LEFT ( _sel, 4 ) )
                    && VALUE ( RIGHT ( _sel, 2 ) ) IN { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
            )
                || (
                    VALUE ( RIGHT ( _sel, 2 ) ) = 2
                        && (
                             (
                                YEAR ( 'Query1'[Call Closed] ) = VALUE ( LEFT ( _sel, 4 ) )
                                    && (
                                        MONTH ( 'Query1'[Call Closed] ) = VALUE ( RIGHT ( _sel, 2 ) )
                                            || MONTH ( 'Query1'[Call Closed] )
                                                = VALUE ( RIGHT ( _sel, 2 ) ) - 1
                                    )
                            )
                                || (
                                     (
                                        YEAR ( 'Query1'[Call Closed] )
                                            = VALUE ( LEFT ( _sel, 4 ) ) - 1
                                            && ( MONTH ( 'Query1'[Call Closed] ) = 12 )
                                    )
                                )
                        )
                )
                || (
                    VALUE ( RIGHT ( _sel, 2 ) ) = 1
                        && (
                             (
                                YEAR ( 'Query1'[Call Closed] ) = VALUE ( LEFT ( _sel, 4 ) )
                                    && ( MONTH ( 'Query1'[Call Closed] ) = VALUE ( RIGHT ( _sel, 2 ) ) )
                            )
                                || (
                                     (
                                        YEAR ( 'Query1'[Call Closed] )
                                            = VALUE ( LEFT ( _sel, 4 ) ) - 1
                                            && (
                                                MONTH ( 'Query1'[Call Closed] ) = 12
                                                    || MONTH ( 'Query1'[Call Closed] ) = 11
                                            )
                                    )
                                )
                        )
                )
        )
    )

result9291109.gif

 

You can download this to check.

 

 

Best Regards,

Stephen Tao

 

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

negi007
Community Champion
Community Champion

@greeshma I couldn't open the file as I have the previous version of Power Bi. But you can check the links below for your problem

http://sqljason.com/2018/03/display-last-n-months-selected-month-using-single-date-dimension-in-powe...

https://stackoverflow.com/questions/49146565/show-last-3-months-from-selected-month-in-power-bi

https://radacad.com/only-get-the-last-few-periods-of-data-into-power-bi-using-power-query-filtering




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



Proud to be a Super User!


Follow me on linkedin

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.