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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Vik49111
Frequent Visitor

Slicer with selection of Date Periods (Year, Quarter, Month)

I am trying to create a slicer where I can select the period (e.g Yearly, Monthly, Quarterly) with monthly snapshot of data and the date period will be populated with the correct values in another slicer as of date (for e.g if Oct 2024 selected in single selection slicer) then following output will shown on dashboard -

If monthly then oct 2024, sep 2024, aug 2024........up to last 13 months in bar chart in the same visual,
If quarter then 2024-Q3, 2024-Q2, 2024-Q1 up to last 5 quarters in bar chart
if yearly then 2024, 2023, 2022 up to last 3 years in the same visual.

 

I only have monthly snapshot of data in one table. I created date table with all the values from starting to end date and create date relationship between two on month year.

 

Although I have seen an article explaining the methodology on how to do it... im struggling to find it.
here is the article which I am currently referring on, with additional as of date slicer- 
https://community.fabric.microsoft.com/t5/Desktop/Slicer-with-selection-of-Date-Periods-Year-Quarter...

I am only able to get the same selected month data, please help me if there is any other way to simplify this  -

 

I am writing this dax but not sure how can i get previous months data as ALL and RemoveFilters does not work in my dax - also I am not sure how to write dax for yearly and quarterly based on monthly snapshot. I think its because power bi does not take values in Axis as parameter and single selected filter value in slicer which also comes from the parameter -

Terms =

var CurrentDate = MAX('Date'[Date]) // want to know how we can take monthly in same format and quarterly, yearly dates
var PreviousDate = DATE(YEAR(CurrentDate), MONTH(CurrentDate) - 13, DAY(CurrentDate))

VAR Result =
SWITCH (
SELECTEDVALUE ( 'Slicer Type'[Type] ),
"Yearly",

CALCULATE (
    DISTINCTCOUNT(term[term]),  FILTER(term, term[Status] = "Terminated")
        ,TREATAS ( VALUES ( 'Date Slicer'[Period] ), term[Year New] ), here i want to add date filter values but that does not support when i create parameters)

, "Quarterly",

CALCULATE (
    DISTINCTCOUNT(term[term]),  FILTER(term, term[Status] = "Terminated")
        ,TREATAS ( VALUES ( 'Date Slicer'[Period] ), term[Quarter New] ), here i want to add date filter values but that does not support when i create parameters)

,"Monthly",

CALCULATE (
    DISTINCTCOUNT(term[term]),  FILTER(term, term[status] = "Terminated")
        ,TREATAS ( VALUES ( 'Date Slicer'[Period] ), term[Month New] ), here i want to add date filter values but that does not support when i create parameters)

,"Checkagain")
RETURN
Result


I already have tried to create parameter from field selection but that does not give me single selection period so I changed to above resolution but now I am having difficulties in creating DAX.

Any help will be much appreciated

5 REPLIES 5
Vik49111
Frequent Visitor

Thank you @lbendlin  for your reply. 13 is just the random month number. I know it should be 12 or last finance year start period. but in quarter I want to see last 5 quarters and atleast 2-3 previous years. I am testing this based only on parameter right now but we can create date table aswell and try above e.g output will remain same. I am looking for measure which switch values in X-axis aswell with period single selection.
Please Let me know if you are able to generate quarter, month and yearly view on same visual using this. or if you need anything else.
sorry I dont have any option to upload and share file permission. I can share pic what i created in sample file -

Vik49111_0-1729864511022.pngVik49111_1-1729864583066.png

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Sorry I dont have any option to upload in power BI (PBI is just making it hard for users) and share file permission in org. I can only describe and upload screenshot.

I cannot assist you if you are unable to provide sample data. I hope someone else can help you further.

lbendlin
Super User
Super User

var PreviousDate = DATE(YEAR(CurrentDate), MONTH(CurrentDate) - 13, DAY(CurrentDate))

That is very, uhm, original, but you would rather want to use 

 

var PreviousDate = EDATE(CurrentDate,-13)

 

Why 13, by the way?

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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