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

Slicer 2 months ago

Hi,

 

Im trying to get my report to show, upon selecting year-month in the slicer, 1 month and 20 days ago.

 

So If I select 2020-04 I need my table visual to only display values with a required fix date in the range 1 Feb - 10 March.

 

This needs needs to be moving with the slicer months. My code currently is below but its not aligning with the dates.

 

8. =
var _startDate = DATEADD(DimDate[Date],-2,MONTH)
var _startPeriod = STARTOFMONTH(_startDate)
var _endDate = DATEADD(DimDate[Date], -1, MONTH)
var _endPeriod = STARTOFMONTH(_endDate) + 9
RETURN
CALCULATE(SUMX(vwtest,vwtest[Count1]), DATESBETWEEN(vwtest[RequiredFix], _startPeriod, _endPeriod) )
 
Am I approaching this correctly, or do I have to be amending the formula for the measure?
 
Thanks in advance
 
Liam
3 REPLIES 3
Greg_Deckler
Super User
Super User

Well, you are if you are getting the correct result! 🙂

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

If you are not getting the intended result, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
az38
Community Champion
Community Champion

Hi @Anonymous 

DATEADD() is a very tricky function

according https://docs.microsoft.com/en-us/dax/dateadd-function-dax

The result table includes only dates that exist in the dates column.

If the dates in the current context do not form a contiguous interval, the function returns an error.

I recommend you to try first to replace dateadd() to statements like

var _endDate = DATE(YEAR(DimDate[Date]), MONTH(DimDate[Date])-1, DAY(DimDate[Date]) )

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Hi @az38 ,

 

Many thanks for your replies with this.

 

It does feel like its not possible though to do with a table visual and a rolling month slicer 2 months in advance.

 

Thanks

 

Liam

 

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.

Top Solution Authors