- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

¿Cómo crear una columna calculada para restar el valor de fila anterior?
Hola
Necesito crear una columna calculada que resta el valor de fila actual del valor de fila anterior en función de la fecha y el nombre del cliente. Por ejemplo:
Fecha | Valor | Cliente | Calc_column (valor esperado) |
01-04-2020 | 100 | A | |
01-04-2020 | 400 | B | |
01-04-2020 | 500 | C | |
02-04-2020 | 120 | A | 20 |
02-04-2020 | 440 | B | 40 |
02-04-2020 | 560 | C | 60 |
¡Gracias de antemano!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hola @ashrafkotb
Tratar
Calc_column =
var _thisDate = Table[Date]
var _prevDate = CALCULATE(MAX(Table[Date]), ALLEXCEPT(Table, Table[Customer]), Table[Date] < _thisDate )
RETURN
Table[Value] - CALCULATE(MAX(Table[Value]), ALLEXCEPT(Table, Table[Customer]), Table[Date] = _prevDate )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Vea mi artículo sobre el tiempo medio entre el error (MTBF) que utiliza EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...
Así que en tu caso, algo como:
Calc_column =
VAR __PreviousDate = MAXX(FILTER('Table',[Date] < EARLIER([Date]) && [Customer] = EARLIER([Customer])),[Date])
VAR __PreviousValue = MAXX(FILTER('Table',[Date] = __PreviousDate) && [Customer] = EARLIER([Customer])),[Date])
RETURN
[Value] - __PreviousValue
Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Pruebe nuevas columnas como
Fecha máxima: maxx(filter(Table, table[Date]<earlier(Table[Date]) && table[Customer]-earlier(Table[Customer])),Table[Date])
diff - Table[value] - maxx(filter(Table, table[Date]-earlier(Table[max date]) && table[Customer]-earlier(Table[Customer])),Table[value])
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hola @ashrafkotb
Tratar
Calc_column =
var _thisDate = Table[Date]
var _prevDate = CALCULATE(MAX(Table[Date]), ALLEXCEPT(Table, Table[Customer]), Table[Date] < _thisDate )
RETURN
Table[Value] - CALCULATE(MAX(Table[Value]), ALLEXCEPT(Table, Table[Customer]), Table[Date] = _prevDate )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
06-05-2024 06:35 PM | |||
12-21-2023 04:48 AM | |||
03-08-2024 08:58 AM | |||
07-02-2024 02:27 PM | |||
03-10-2024 11:19 PM |