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
Mugizib
Regular Visitor

Problem finding single day value

Hi everyone, I'm having a problem that should be very simple to solve but I've looked everywhere and couldn't find an answer.

 

I have a table, like the image below:

Mugizib_0-1674931783214.png

In this table I have a name of an individual [name], a date [date] and a running value of this persons total xp [xp].

 

What I've been strugling is to find the value for each person of each single day. For example, for the character Ulvis, the xp today should be (Ulvis [xp] today) - (Ulvis [xp] yesterday) and so on.

 

I managed to create a column where it sort of works, but not completely, because the xp can increase and also decrease, and this formula doesn't work if the xp decreases from one day to the other:

 
XP Diaria =
VAR _maxvalue =
         CALCULATE (
                MAX ( 'XP por dia'[xp] ),
                FILTER (
                         'XP por dia',
                         'XP por dia'[name] = EARLIER ( 'XP por dia'[name] )
                         && 'XP por dia'[Índice] < EARLIER ( 'XP por dia'[Índice] )
                )
         ) 
 
RETURN
          'XP por dia'[xp] - _maxvalue

 

Here is my result: 

namevocationlevelxpdateÍndiceXP Diaria
Best KinaElder Druid4351.358.049.62821/01/20236711.358.049.628
Best KinaElder Druid4351.353.809.18222/01/20231621-4.240.446
Best KinaElder Druid4351.353.809.18223/01/20232571-4.240.446
Best KinaElder Druid4351.354.952.48024/01/20233524-3.097.148
Best KinaElder Druid4341.349.341.09725/01/20234477-8.708.531
Best KinaElder Druid4351.356.881.47726/01/20235423-1.168.151
Best KinaElder Druid4361.366.596.98827/01/202363698.547.360
Best KinaElder Druid4361.366.596.98828/01/202373220
UlvisElder Druid5422.629.227.13121/01/20234132.629.227.131
UlvisElder Druid5432.639.848.79222/01/2023136410.621.661
UlvisElder Druid5442.656.424.54223/01/2023231016.575.750
UlvisElder Druid5452.670.269.46424/01/2023326113.844.922
UlvisElder Druid5462.684.681.94525/01/2023420914.412.481
UlvisElder Druid5472.702.924.96826/01/2023515418.243.023
UlvisElder Druid5482.718.618.34627/01/2023610515.693.378
UlvisElder Druid5492.734.267.72928/01/2023705315.649.383

 

And here is the expected result:

namevocationlevelxpdateÍndiceXP Diaria
Best KinaElder Druid4351.358.049.62821/01/20236711.358.049.628
Best KinaElder Druid4351.353.809.18222/01/20231621-4.240.446
Best KinaElder Druid4351.353.809.18223/01/202325710
Best KinaElder Druid4351.354.952.48024/01/202335241.143.298
Best KinaElder Druid4341.349.341.09725/01/20234477-5.611.383
Best KinaElder Druid4351.356.881.47726/01/202354237.540.380
Best KinaElder Druid4361.366.596.98827/01/202363699.715.511
Best KinaElder Druid4361.366.596.98828/01/202373220
UlvisElder Druid5422.629.227.13121/01/20234132.629.227.131
UlvisElder Druid5432.639.848.79222/01/2023136410.621.661
UlvisElder Druid5442.656.424.54223/01/2023231016.575.750
UlvisElder Druid5452.670.269.46424/01/2023326113.844.922
UlvisElder Druid5462.684.681.94525/01/2023420914.412.481
UlvisElder Druid5472.702.924.96826/01/2023515418.243.023
UlvisElder Druid5482.718.618.34627/01/2023610515.693.378
UlvisElder Druid5492.734.267.72928/01/2023705315.649.383

 

Thanks in advance!

Best regards!

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

Hi @Mugizib ,

 

Please try:

Column = 
var _index = MAXX(FILTER('XP por dia',[name]=EARLIER('XP por dia'[name])&&[Índice]<EARLIER('XP por dia'[Índice])),[Índice])
VAR _maxvalue =
         CALCULATE (
                MAX ( 'XP por dia'[xp] ),
                FILTER (
                         'XP por dia',
                         'XP por dia'[name] = EARLIER ( 'XP por dia'[name] )
                         && 'XP por dia'[Índice] = _index
                )
         ) 
 
RETURN
[xp]-_maxvalue

Final output:

vjianbolimsft_0-1675047599463.png

Best Regards,

Jianbo Li

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

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

Hi @Mugizib ,

 

Please try:

Column = 
var _index = MAXX(FILTER('XP por dia',[name]=EARLIER('XP por dia'[name])&&[Índice]<EARLIER('XP por dia'[Índice])),[Índice])
VAR _maxvalue =
         CALCULATE (
                MAX ( 'XP por dia'[xp] ),
                FILTER (
                         'XP por dia',
                         'XP por dia'[name] = EARLIER ( 'XP por dia'[name] )
                         && 'XP por dia'[Índice] = _index
                )
         ) 
 
RETURN
[xp]-_maxvalue

Final output:

vjianbolimsft_0-1675047599463.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@Mugizib Mean Time Between Failure (MTBF) - Microsoft Power BI Community


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.