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

Difference between two points

Hi Guys,

 

I have data that is not transactional. Each entry is the current value for that month. Thus it's not data such as sales that can be summed but rather a single value at a point in time.

My objective is to determine the difference between the value for this month and six months prior. All the examples use a variation of this Datesbetween formula:

 

Delta =
CALCULATE(sum(Sales[Monthly Sales]),
DATESBETWEEN('Calendar'[Date],
Max('Calendar'[Date]) - 180,
Max('Calendar'[Date])))
 
This doesn't work as I don't 'Sum' my data. See the image below:
 
Lost Sales.PNG

 

I just want to do simple math and determine 2000 (From this month) - 2500 (From 6 months ago) = -500. Can't get it right at all!
 
Thanks
 
 
 
 
 
6 REPLIES 6
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @JBI ,

For your requirement, you could refer to the measure below. You could modify it based on your scenario.

Measure =
VAR c_m =
    CALCULATE (
        SUM ( 'Sales'[Project Sales] ),
        FILTER (
            'Calendar',
            'Calendar'[Month] = MAX ( 'Sales'[Month] )
                && 'Calendar'[Date].[Year] = MAX ( 'Sales'[year] )
        )
    )
VAR c_m_6 =
    CALCULATE (
        SUM ( 'Sales'[Project Sales] ),
        DATEADD ( 'Sales'[Date_column], -6, MONTH )
    )
RETURN
    c_m - c_m_6

Here is the output.

Capture.PNG

For more details, please refer to my attchment.

Best  Regards,

Cherry

 

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

You could try something like 

CALCULATE(

                    SUM(

                             Sales[Monthly Sales]

                            )

                    )

-

CALCULATE(

                    SUM(

                             Sales[Monthly Sales]),

                    FILTER(

                               ALL('Calendar'), 

                               'Calendar'[Date]=Max('Calendar'[Date]) - 180

                               )

                   )

 

BR

JBI
Frequent Visitor

It's still returning the whole table. I want a scalar value returned. Surely there should be a simple way to do calculations like this in PowerBI

Hi @JBI ,

Have you solved your problem?

If you have solved, please  always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please feel free to ask.

Best Regards,

Cherry

 

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

Hi,

Did not get solution no. I got a solution on a different feed.

 

Thanks

Hi @JBI ,

If you get a solution, could you share and accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

Best Regards,

Cherry

 

 

Community Support Team _ Cherry Gao
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.