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
coryan
New Member

Restar valores acumulados de distintas fechas

hola! Tengo una tabla con valores acumulados por fecha, es decir tengo una columna fecha y otra columna valor. Mi pregunta es como puedo restar 2 valores entre diferentes fechas? Por ejemplo: Fecha.      Valor acumulado

   1 Diciembre 2019.   20 

    5 Enero 2020.          30

   2 Febrero 2020.       40

   3 Abril 2020            120

Como podria hacerlo si quiero restar por ejemplo el valor del 3 de abril menos el del 1 de diciembre de 2019? Gracias

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

Hi @coryan ,

You can create a measure as below:

Difference = 
VAR _minvalue =
    CALCULATE (
        MAX ( 'Ttable'[Accumulated value] ),
        FILTER ( 'Ttable', 'Ttable'[Date] = MIN ( 'Ttable'[Date] ) )
    )
VAR _maxvalue =
    CALCULATE (
        MAX ( 'Ttable'[Accumulated value] ),
        FILTER ( 'Ttable', 'Ttable'[Date] = MAX ( 'Ttable'[Date] ) )
    )
RETURN
    _maxvalue - _minvalue

Subtract accumulated values from different dates.JPG

Best Regards

Rena

Community Support Team _ Rena
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-yiruan-msft
Community Support
Community Support

Hi @coryan ,

You can create a measure as below:

Difference = 
VAR _minvalue =
    CALCULATE (
        MAX ( 'Ttable'[Accumulated value] ),
        FILTER ( 'Ttable', 'Ttable'[Date] = MIN ( 'Ttable'[Date] ) )
    )
VAR _maxvalue =
    CALCULATE (
        MAX ( 'Ttable'[Accumulated value] ),
        FILTER ( 'Ttable', 'Ttable'[Date] = MAX ( 'Ttable'[Date] ) )
    )
RETURN
    _maxvalue - _minvalue

Subtract accumulated values from different dates.JPG

Best Regards

Rena

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

I have the same problem, but I need to know if the result of the difference is positive or negative, so, I think that I should not use MAXX and MINX ¿Do you know how can I solve it?

 

Example:

 

    1 Diciembre 2019.   20 

    5 Enero 2020.          30

    2 Febrero 2020.       40

    3 Abril 2020            120

    5 Mayo 2020           50

 

If I want to know the difference between Mayo and Enero, the result will be 20 (50-20), but if I took Mayo and Abril the result should be -70 (50-120), in order to know if I have proffit or loss.

 

amitchandak
Super User
Super User

@coryan , These formula's can help

 

Last Day Non Continuous = CALCULATE([sales],filter(ALLSELECTED('Date'),'Date'[Date] =MAXX(FILTER(ALLSELECTED('Date'),'Date'[Date]<max('Date'[Date])),'Date'[Date])))

or
Day behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Day))

or
Last Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))

or

Last Day = CALCULATE(sum('order'[Qty]), previousday('Date'[Date]))

 

This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))

 

refer by blog, the column way is also given

https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

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.