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
TEACHY888
Regular Visitor

Dynamic Date Range selection of two Date Column by 1 Slicer

Hi Gurus, really stucked here and need some help. 

OpportunityOldValue_NewValue table got two Date Column Changed_Date and OpportunityCreatedDate .
I need to create a dateSlicer / daterange on ChangedDate column which should also filter CreatedColumn and show the amount
So far I have tried this but its not working :
 
NewCalculation1 =
VAR StartDate = CALCULATE(MIN(OpportunityOldValue_NewValue[Changed_Date].[Date]), ALL(OpportunityOldValue_NewValue[OpportunityCreatedDate]))
VAR EndDate = CALCULATE(MAX(OpportunityOldValue_NewValue[Changed_Date].[Date]), ALL(OpportunityOldValue_NewValue[OpportunityCreatedDate]))
VAR LatestChangedDateTime = CALCULATE(MAX(OpportunityOldValue_NewValue[Changed_Date]), ALL(OpportunityOldValue_NewValue))

RETURN
IF(ISBLANK(CALCULATE(
    SELECTEDVALUE(OpportunityOldValue_NewValue[Amount]),
    FILTER(
        OpportunityOldValue_NewValue,
        OpportunityOldValue_NewValue[Changed_Date] = LatestChangedDateTime &&
        OpportunityOldValue_NewValue[Changed_Date] >= StartDate &&
        OpportunityOldValue_NewValue[Changed_Date] <= EndDate &&
        OpportunityOldValue_NewValue[OpportunityCreatedDate] >= StartDate &&
        OpportunityOldValue_NewValue[OpportunityCreatedDate] <= EndDate
    )
)), 0,
CALCULATE(
    SELECTEDVALUE(OpportunityOldValue_NewValue[Amount]),
    FILTER(
        OpportunityOldValue_NewValue,
        OpportunityOldValue_NewValue[Changed_Date] = LatestChangedDateTime &&
        OpportunityOldValue_NewValue[Changed_Date] >= StartDate &&
        OpportunityOldValue_NewValue[Changed_Date] <= EndDate &&
        OpportunityOldValue_NewValue[OpportunityCreatedDate] >= StartDate &&
        OpportunityOldValue_NewValue[OpportunityCreatedDate] <= EndDate
    )
))
 
Really need some helpm here and any input would be appriciated , thanks
1 REPLY 1
lbendlin
Super User
Super User

create an active relationship between the date on your calendar table and the create date. Create an inactive relationship between the calendar date and the change date.  use USERELATIONSHIP in your measures to toggle between the joins.

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.