Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Burubear
Helper I
Helper I

MAX value for each date until Goal (not running total)

Hello everyone!

 

Been looking into dax solutions for my scenario but can't seem to get the right for my spefic scenario. For my report, I currently have a data set like this: (below is just a sample but for scale my duration is for around 5 years and with 10 locations)

 

DateLocation ALocation BTotal
1/1/20200.3000.3250.62500
1/2/20200.6000.6501.25000
1/3/20200.9000.9751.87500
1/4/20201.2001.3002.50000
1/5/20201.5001.6253.12500
1/6/20201.8001.9503.75000
1/7/20202.1002.2754.37500
1/8/20202.4002.6005.00000
1/9/20202.7002.9255.62500
1/10/20203.0003.2506.25000
1/11/20203.3003.5756.87500
1/12/20203.6003.9007.50000
1/13/20203.9004.2258.12500
1/14/20204.2004.5508.75000
1/15/20204.5004.8759.37500
1/16/20204.5005.2009.70000
1/17/20204.5005.52510.02500
1/18/20204.5005.85010.35000
1/19/20204.5006.17510.67500
1/20/20204.5006.50011.00000

 

Scenarios are the ff:

1. I have two locations with a total savings goal given their own set of target date:

     Location A Target date: 1/15/2020 with $4.5 savings

     Location B Target date: 1/20/2020 with $6.5 savings

2. Table shows the somewhat history log daily growth of each location until it finally got to it's goal on their respective dates. So as you can see, Location A is still showing 4.5 after 1/15/2020 because it has reached it's goal

3. I used the total column to use in area chart to see the day to day increase until the final target date for all locations. Used MAX value rather than SUM since it's day to day growth

4. I created another bar chart to show now each locations progress. X- axis using the savings.  Y axis using the Location. For do this I duplicate the same data set, removed the total then unpivot the locations so it would be in 2 columns: Location and Savings

 

What I want to achieve is when I click on a certain period in the area chart, let's say 1/17/2020. The bar chart will move along it so Location A will have full bar since it's total goal is already set, but for Location B it should only show the 5.525 as the highlighted portion since the Goal of 6.5 is still not yet met on that day. Same goes with using slicers dates and not just the highlighting part 

 

Sorry if my explanation is a bit confusing. Am really open to using dax or changing my approach on the tables 

1 ACCEPTED SOLUTION
JW_van_Holst
Resolver IV
Resolver IV

It's a bit hard to understand your problem. 
General Advice:
1. always unpivot your data before you start in DAX
2. work with deltas in your columns (instead of cumulatives)

 

Day Savings = 
VAR __filter = FILTER('Table', 'Table'[Location] = EARLIER('Table'[Location]) && 'Table'[Date] = EARLIER('Table'[Date]) -1)
VAR __cumSavingsPreviousDay = MAXX(__filter, 'Table'[**bleep** Savings])
RETURN
'Table'[**bleep** Savings] - __cumSavingsPreviousDay

 


However neither should represent a problem in your case. For clarity I made a screenshot of a matrix and a slicer and they give the result you want (as I understand it)


Picture1.png

 

View solution in original post

2 REPLIES 2
JW_van_Holst
Resolver IV
Resolver IV

It's a bit hard to understand your problem. 
General Advice:
1. always unpivot your data before you start in DAX
2. work with deltas in your columns (instead of cumulatives)

 

Day Savings = 
VAR __filter = FILTER('Table', 'Table'[Location] = EARLIER('Table'[Location]) && 'Table'[Date] = EARLIER('Table'[Date]) -1)
VAR __cumSavingsPreviousDay = MAXX(__filter, 'Table'[**bleep** Savings])
RETURN
'Table'[**bleep** Savings] - __cumSavingsPreviousDay

 


However neither should represent a problem in your case. For clarity I made a screenshot of a matrix and a slicer and they give the result you want (as I understand it)


Picture1.png

 

Thank you for the guidelines, I'll take note of that for futureu data sets as well.

 

EDIT: Sorry I didn;t notice that you are referring to making Dax Columns and not measure. All is good now. Thank you so much  

As for the Dax formula, is it possible to show me the Formula bar as well? I tried following your formula above but for the "EARLIER" function, it won't allow me to use a table column. There are no table columns in the suggested fields after EARLIER then when I just manually type it, it won't take it. Let me know if i'm reading the formula wrong

 

Screenshot 2021-02-09 073415.png

Helpful resources

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

Top Solution Authors
Top Kudoed Authors