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
Anonymous
Not applicable

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, @Anonymous 

  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, @Anonymous 

  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.

 

Anonymous
Not applicable

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
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.