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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
TDisco
Helper I
Helper I

Filter date ranges based on text filter value

Having an issue building a Filter dropdown with ‘names’ that aggregate dates. I get a feeling it’s a Power BI concept I’m not grasping. Have search many solutions for many days. This is what I currently have:

 

A separate table with the following “Selection” values (with their intent):

  • Current Reporting Month (The previous month)
  • Previous Month (2 months ago)
  • Last Three months (not including current month)

The Column used in a table for this Filter:

mm_slicer =

IF(HASONEFILTER(Date_Slicer[Selection]),

    SWITCH(SELECTEDVALUE(Date_Slicer[Selection]),

        "Current Reporting Month", tbl_MetricsMerge[mm_sum_UnplannedMinutes_current],

        "Previous Month", tbl_MetricsMerge[mm_sum_UnplannedMinutes_previous],

        "Last 3 Months", tbl_MetricsMerge[mm_sum_UnplannedMinutes_last3]

    ),

   tbl_MetricsMerge[mm_sum_UnplannedMinutes_current]

)

 

DAX for the three values mentioned above:

  • mm_sum_UnplannedMinutes_current = CALCULATE(SUM('tbl_MetricsMerge'[MetricResult]),'tbl_MetricsMerge'[Metric] = "Unplanned Downtime Minutes" , DATEDIFF (tbl_MetricsMerge[Date], TODAY (), MONTH) = 1)
  • mm_sum_UnplannedMinutes_previous = CALCULATE(SUM('tbl_MetricsMerge'[MetricResult]),'tbl_MetricsMerge'[Metric] = "Unplanned Downtime Minutes" , DATEDIFF (tbl_MetricsMerge[Date], TODAY (), MONTH) = 2)
  • mm_sum_UnplannedMinutes_last3 = CALCULATE(SUM('tbl_MetricsMerge'[MetricResult]),'tbl_MetricsMerge'[Metric] = "Unplanned Downtime Minutes", DATEDIFF (tbl_MetricsMerge[Date], TODAY (), MONTH) <= 3)

 

I can load these measures individually into a table, and see the values as needed. Wonderful – thumbs up.

 

HOWEVER, when using the mm_slicer measure in a table that applies the Filter, the first “current” and “previous” work, but the “last3” does not, it will only display the third month. How can I get a rolling value of 3 months?

 

Issues to be resolved:

  • Calculate a 3-month rolling sum (Previous month plus 2 more)
  • Filter to count only a specific type of value (Unplanned Downtime Minutes)

 

PS: The tbl_MetricsMerge dataset contains the first day of every month for 2022 (which is used as a placeholder in the data entry form this data is attached to.)

PSS: I have a "Date" table.

 

TDisco_0-1642005419130.png

 

 

1 ACCEPTED SOLUTION
TDisco
Helper I
Helper I

I had a relationship link from the Date Selector to the Date Table. Removing that made all this work.

View solution in original post

8 REPLIES 8
TDisco
Helper I
Helper I

I had a relationship link from the Date Selector to the Date Table. Removing that made all this work.

v-yalanwu-msft
Community Support
Community Support

Hi, @TDisco ;

I tested it , It's all true in the cases I tested. Maybe you missed something that we didn't notice. For example, your table has other filters, and secondly, you can compare your [MM_slicer] and [mm_sum_UnplannedMinutes_last3] in a table. The external conditions all reduce the variables.

vyalanwumsft_0-1642404511265.png

vyalanwumsft_1-1642404586625.png

Or you could share more detail about your  structure and relationships of the data, or a simple file?Looking forward your reply!
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Lets try one more screen shot. Here is the file Google Drive (temp link)

 

And hey. thanks for sticking with me on this 😃

 

See image. No filters are present, except for what is in the measures.

  1. Filter is linked to Table (only this table)
  2. The measure to build the links and the measures placed in a table.
    • I added a test_3rdmonth measure to validate the _last3 measure
  3. All the measures are written like this.  The _last3 should equal the sum of these three measures: _current, _previous, _test_3rdmonth - which it does in the "2" table - but when used with the filter in table "1" - only returns the 3rd month value and not the last 3 month sum.

 

Dataset. is trimmed for just two systems.

  • Column – Data Type
  • System is Text
  • Metric is Text
  • Date is Date (All Dates are for start of every month = January 2021 – 1/1/2021)
  • MetricResult is General (Not Summarized)
 
 

2022-01-18_6-55-27.jpg

Hi, @TDisco ;

I can't really judge from the screenshot you gave, your link needs permission to open.

vyalanwumsft_0-1642557832651.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Do you recommend another method to share the file?

TDisco
Helper I
Helper I

A simpler recap. I have a filter that has words. I have a measure column, that based on the word selcted, runs one of 3 measures. The measures contain a formula that matches the a SUM value of the word. All these measures return the correct values (I can prove that by putting in a stand alone table) While I can get Current and Previous month to return a correct value, I'm not able to return a rolling 3-month count. (this DAX works and is proven in a table).... Any reason it would work in a table, but not in filtered measure? - Thanks (edits - clarity)

amitchandak
Super User
Super User

@TDisco , if there is no interaction between visuals, then it should take default value and show value for that

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors