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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

data manuplation

hiiii

i have a line graph with 3 different calculations in it which shows 3 different months JAN FEB MAR 

i want to use a button if i click on april my graph should display FEB MAR and APRIL data 

that means it should show two previous mnths data and 1 present mnth data.

https://drive.google.com/file/d/1aGOdgI-FCuB9b5VcVxs6jsp7OzeLbuMc/view?usp=sharing 

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

Hi @Anonymous ,

 

I think it is better to use a slicer rather than a button to change the values. Because we don't need to create 12 buttons for each month. I create a simple sample please have a try.

 

Create a new table and use its column as slicer:

 

Table =
ADDCOLUMNS (
    FILTER ( VALUES ( Query1[Call Closed] ), [Call Closed] <> BLANK () ),
    "Year", YEAR ( [Call Closed] ),
    "Month", MONTH ( [Call Closed] ),
    "MonthName", FORMAT ( [Call Closed], "MMMM" )
)

 

 

Sort the "MonthName" column by "Month" column:

v-xuding-msft_1-1599466683418.png

 

Use MonthName column as slicer and change its orientation to horizontal:

v-xuding-msft_0-1599466623616.png

 

Create measures:

 

Selected Slicer = SELECTEDVALUE('Table'[Month])
RAW_SLA% 1 = 
CALCULATE (
    [RAW SLA%],
    FILTER (
        Query1,
        Query1[Call Closed].[MonthNo] <= [Selected Slicer]
            && Query1[Call Closed].[MonthNo] >= [Selected Slicer] - 2
            && Query1[Call Closed].[Year] = YEAR ( TODAY () )
    )
)
M.SLA% 1 = 
CALCULATE (
    [M.SLA%],
    FILTER (
        Query1,
        Query1[Call Closed].[MonthNo] <= [Selected Slicer]
            && Query1[Call Closed].[MonthNo] >= [Selected Slicer] - 2
            && Query1[Call Closed].[Year] = YEAR ( TODAY () )
    )
)
Count of Call Closed 1 = 
CALCULATE (
    COUNT(Query1[Call Closed]),
    FILTER (
        Query1,
        Query1[Call Closed].[MonthNo] <= [Selected Slicer]
            && Query1[Call Closed].[MonthNo] >= [Selected Slicer] - 2
            && Query1[Call Closed].[Year] = YEAR ( TODAY () )
    )
)

 

v-xuding-msft_3-1599466872145.png

 

 

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.

View solution in original post

3 REPLIES 3
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

I think it is better to use a slicer rather than a button to change the values. Because we don't need to create 12 buttons for each month. I create a simple sample please have a try.

 

Create a new table and use its column as slicer:

 

Table =
ADDCOLUMNS (
    FILTER ( VALUES ( Query1[Call Closed] ), [Call Closed] <> BLANK () ),
    "Year", YEAR ( [Call Closed] ),
    "Month", MONTH ( [Call Closed] ),
    "MonthName", FORMAT ( [Call Closed], "MMMM" )
)

 

 

Sort the "MonthName" column by "Month" column:

v-xuding-msft_1-1599466683418.png

 

Use MonthName column as slicer and change its orientation to horizontal:

v-xuding-msft_0-1599466623616.png

 

Create measures:

 

Selected Slicer = SELECTEDVALUE('Table'[Month])
RAW_SLA% 1 = 
CALCULATE (
    [RAW SLA%],
    FILTER (
        Query1,
        Query1[Call Closed].[MonthNo] <= [Selected Slicer]
            && Query1[Call Closed].[MonthNo] >= [Selected Slicer] - 2
            && Query1[Call Closed].[Year] = YEAR ( TODAY () )
    )
)
M.SLA% 1 = 
CALCULATE (
    [M.SLA%],
    FILTER (
        Query1,
        Query1[Call Closed].[MonthNo] <= [Selected Slicer]
            && Query1[Call Closed].[MonthNo] >= [Selected Slicer] - 2
            && Query1[Call Closed].[Year] = YEAR ( TODAY () )
    )
)
Count of Call Closed 1 = 
CALCULATE (
    COUNT(Query1[Call Closed]),
    FILTER (
        Query1,
        Query1[Call Closed].[MonthNo] <= [Selected Slicer]
            && Query1[Call Closed].[MonthNo] >= [Selected Slicer] - 2
            && Query1[Call Closed].[Year] = YEAR ( TODAY () )
    )
)

 

v-xuding-msft_3-1599466872145.png

 

 

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.
Greg_Deckler
Community Champion
Community Champion

@Anonymous - You can use bookmarks for that or you can do something like the Complex Selector - https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Complex-Selector/m-p/1116633#M534



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Anonymous , if want choose a month display more data with month name

 

refer

https://www.youtube.com/watch?v=duMSovyosXE

 

You can also use time intelligence with date table

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last to last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-2,MONTH)))

previous month value =  CALCULATE(sum('table'[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

previous to previous month value =  CALCULATE(sum('table'[total hours value]),previousmonth(dateadd('Date'[Date],-1,MONTH)))

Last year same month value =  CALCULATE(sum('table'[total hours value]),previousmonth(dateadd('Date'[Date],-12,MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors