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
Lmc_08
Frequent Visitor

Trailing 12 Months to work with other visuals

Hi,

I've been working on a trailing 12 months line graphy which is on the same report page as other visuals which need to be filtered to the date level. I've managed to get the trailing 12 months graph to work using a disconnected table, but this runs into the issue of needing two date slicers. What I would like to see is if I select e.g. 31st December 2019, the line graph shows the values for the previous 12 months, and the other visuals to show the value for just the 31st December. Is this possible?

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

Hi @Lmc_08 ,

 

You can create an inactive relationship between your disconnected table with your fact table and use USERELATIOSHIP function in your formula.

 

For the measure you wan to shows the values for previous 12 months before the selected date:

 

Measure for previous 12 months =
VAR A =
    MAX ( 'Table'[Date] )
VAR B =
    DATEADD ( 'Table'[Date], -12, MONTH )
RETURN
    CALCULATE (
        SUM ( 'Fact'[Value] ),
        FILTER ( 'Fact', 'Fact'[Date] <= A && 'Fact'[Date] >= B )
    )

 

For the measure you wan to shows the values for the selected date:

Measure for Selected date =
VAR A =
    MAX ( 'Table'[Date] )
VAR B =
    DATEADD ( 'Table'[Date], -12, MONTH )
RETURN
    CALCULATE (
        SUM ( 'Fact'[Value] ),
        USERELATIONSHIP( 'Table'[Date] ,'Fact'[Date]  )
    )

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @Lmc_08 ,

 

You can create an inactive relationship between your disconnected table with your fact table and use USERELATIOSHIP function in your formula.

 

For the measure you wan to shows the values for previous 12 months before the selected date:

 

Measure for previous 12 months =
VAR A =
    MAX ( 'Table'[Date] )
VAR B =
    DATEADD ( 'Table'[Date], -12, MONTH )
RETURN
    CALCULATE (
        SUM ( 'Fact'[Value] ),
        FILTER ( 'Fact', 'Fact'[Date] <= A && 'Fact'[Date] >= B )
    )

 

For the measure you wan to shows the values for the selected date:

Measure for Selected date =
VAR A =
    MAX ( 'Table'[Date] )
VAR B =
    DATEADD ( 'Table'[Date], -12, MONTH )
RETURN
    CALCULATE (
        SUM ( 'Fact'[Value] ),
        USERELATIONSHIP( 'Table'[Date] ,'Fact'[Date]  )
    )

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

amitchandak
Super User
Super User

@Lmc_08 , I think have to follow the approach you have taken,

refer is there is anything different here: https://www.youtube.com/watch?v=duMSovyosXE

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.