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
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it Out!

Join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors