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
PoojaG
Helper II
Helper II

Monthly trend line- Diff between the first month value selected by date filter and last month value

Hello,

I am trying to calculate the difference between the first value selected and last value in the trend line. I was able to achieve that for daily trend. In the picture below. the metric Positive Sentiment Increased by 11% (83% - 72%). Similarly, I would like to do for weekly trend (picture attached below), the metric should display (81%-77% = 4%) and for monthly trend (picture attached below), it should display (82%-79%=3%).

the formula used for daily trend is: 

difference % Positive = 
var startdate = [Start date]
var start_pct=
CALCULATE([% Positive],
FILTER(ALL('Date'[Time Period]),'Date'[Time Period]=startdate))
var enddate = [End date]
var end_pct=
CALCULATE([% Positive],
FILTER(ALL('Date'[Time Period]),'Date'[Time Period]=enddate))
return ABS(end_pct - start_pct)

Daily trendDaily trendMonthly trendMonthly trendWeekly trendWeekly trend

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

Hi @PoojaG ,

 

We can try to use the following measure to get Monthly  Diff  percentage:

 

Monthly difference % Positive =
VAR startdate =
    YEAR ( [Start date] ) * 100
        + MONTH ( [Start date] )
VAR start_pct =
    CALCULATE (
        [% Positive],
        FILTER (
            ALL ( 'Date'[Time Period] ),
            YEAR ( [Time Period] ) * 100
                + MONTH ( [Time Period] ) = startdate
        )
    )
VAR enddate =
    YEAR ( [End date] ) * 100
        + MONTH ( [End date] )
VAR end_pct =
    CALCULATE (
        [% Positive],
        FILTER (
            ALL ( 'Date'[Time Period] ),
            YEAR ( [Time Period] ) * 100
                + MONTH ( [Time Period] ) = enddate
        )
    )
RETURN
    ABS ( end_pct - start_pct )

  


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @PoojaG ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lid-msft
Community Support
Community Support

Hi @PoojaG ,

 

We can try to use the following measure to get Monthly  Diff  percentage:

 

Monthly difference % Positive =
VAR startdate =
    YEAR ( [Start date] ) * 100
        + MONTH ( [Start date] )
VAR start_pct =
    CALCULATE (
        [% Positive],
        FILTER (
            ALL ( 'Date'[Time Period] ),
            YEAR ( [Time Period] ) * 100
                + MONTH ( [Time Period] ) = startdate
        )
    )
VAR enddate =
    YEAR ( [End date] ) * 100
        + MONTH ( [End date] )
VAR end_pct =
    CALCULATE (
        [% Positive],
        FILTER (
            ALL ( 'Date'[Time Period] ),
            YEAR ( [Time Period] ) * 100
                + MONTH ( [Time Period] ) = enddate
        )
    )
RETURN
    ABS ( end_pct - start_pct )

  


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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 Kudoed Authors