cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alumanah
Frequent Visitor

Comparing latest value to previous

Hi There,

 

I am trying to compare latest value for each area(North, East e.t.c) to previous month value to see if it is more, and also trying to see if latest value is more than the target. i.e. 

1. In the "North" the latest month value is greater than target
2. In the "North" the Difference between current month and previous month is ...
3. Value for previous month in the "North" is...

 

I there a way I can go about doing this with measures?

Viewing table.JPG

Really appretiate the help

 

Victor

Below is what the original data looks like

 

ViewingsTargetAprMayJunJulAugSep
North404034554030 
South503322874560 
East40342365445655
West607666876578 
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Alumanah 

  1. For your first question, check whether the value of this month is greater than the target value, create a calculation column "Compare Target", if it exceeds the target value, output Yes, otherwise No.
Compare Target =
IF (
    CALCULATE (
        MIN ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
                && 'Table'[Attribute] = EARLIER ( 'Table'[Attribute] )
        )
    ) > 'Table'[Target],
    "Yes",
    "No"
)

vzhangti_0-1635215065236.png

     2. For your second question, calculate the difference between the current month and the previous month. First create calculation columns to calculate the value of the previous month corresponding to each month in each region, and then calculate the difference.

Last Month =
DATEADD ( 'Table'[Attribute], -1, MONTH )
Last Mouth Value =
CALCULATE (
    MIN ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Attribute] = EARLIER ( 'Table'[Last Month] )
            && 'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
    )
)
Difference Value =
'Table'[Value] - 'Table'[Last Mouth Value]

The process of calculating the difference is shown in the figure:

vzhangti_2-1635215510694.png

      3. If you want to compare whether there are more values than last month, you can create a calculation column "Compare Last Month Value". If there are more values than last month, you will output Yes, otherwise, you will No.

Compare Last Mouth Value =
IF (
    CALCULATE (
        MIN ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Attribute] = EARLIER ( 'Table'[Last Month] )
                && 'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
        )
    ) < 'Table'[Value],
    "Yes",
    "No"
)

vzhangti_3-1635215554468.png

Best Regards,

Charlotte Zhang

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

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @Alumanah 

  1. For your first question, check whether the value of this month is greater than the target value, create a calculation column "Compare Target", if it exceeds the target value, output Yes, otherwise No.
Compare Target =
IF (
    CALCULATE (
        MIN ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
                && 'Table'[Attribute] = EARLIER ( 'Table'[Attribute] )
        )
    ) > 'Table'[Target],
    "Yes",
    "No"
)

vzhangti_0-1635215065236.png

     2. For your second question, calculate the difference between the current month and the previous month. First create calculation columns to calculate the value of the previous month corresponding to each month in each region, and then calculate the difference.

Last Month =
DATEADD ( 'Table'[Attribute], -1, MONTH )
Last Mouth Value =
CALCULATE (
    MIN ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Attribute] = EARLIER ( 'Table'[Last Month] )
            && 'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
    )
)
Difference Value =
'Table'[Value] - 'Table'[Last Mouth Value]

The process of calculating the difference is shown in the figure:

vzhangti_2-1635215510694.png

      3. If you want to compare whether there are more values than last month, you can create a calculation column "Compare Last Month Value". If there are more values than last month, you will output Yes, otherwise, you will No.

Compare Last Mouth Value =
IF (
    CALCULATE (
        MIN ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Attribute] = EARLIER ( 'Table'[Last Month] )
                && 'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
        )
    ) < 'Table'[Value],
    "Yes",
    "No"
)

vzhangti_3-1635215554468.png

Best Regards,

Charlotte Zhang

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

 

Thank you so much this is perfect for what I am trying to acomplish

vanessafvg
Super User
Super User

please provide data in text format. 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors