Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I have a dataset that contains pricing for material, per vendor, and the date range these prices where valid. My goal is to show the price per month and if it changed (price variance). My date slicer is set for all data for this year, however I need to show what that price was at the beinging of the year, so I'm trying to figure out how to see the data prior to the year and then get the LAST price based on the BEG_DATE, per vendor. I came up with a Measure that shows a 1 for dates before the select date range and a 0 what is in the date range. This is the start but I then need to only show the LAST price. Here's a screenshot of what this currently looks like and I'll include the Measure. I will use the 'beginning of year price' as a column in another table. Any help would be greatly appreciated!
Dates B4 Date Range =
VAR MinDate = CALCULATE( MIN( Dates[Date] ), ALLSELECTED( Dates ) )
VAR MaxDate = MAX( Dates[Date] )
VAR CurrYr = CALCULATETABLE(VALUES(FCI_RAWMAT_PRICE_HIST[PROD_ID]),FILTER(ALLSELECTED(Dates),Dates[Date]>=MinDate && Dates[Date]<=MaxDate))
VAR PrevYr = CALCULATETABLE(VALUES(FCI_RAWMAT_PRICE_HIST[PROD_ID]),FILTER(ALL(Dates),Dates[Date]<MinDate))
VAR Result = EXCEPT(PrevYr,CurrYr)
RETURN
IF(COUNTROWS(Result)>0,COUNTROWS(Result),0)
Solved! Go to Solution.
Hi @Jamey
To calculate the beginning-of-year price (last valid price before the selected date range) for each vendor and material, you can use the following DAX measure:
Beginning of Year Price =
VAR MinDate = CALCULATE(MIN(Dates[Date]), ALLSELECTED(Dates))
RETURN
CALCULATE(
MAX(FCI_RAWMAT_PRICE_HIST[PRICE_AMT]),
FCI_RAWMAT_PRICE_HIST[BEG_DATE] <= MinDate,
FCI_RAWMAT_PRICE_HIST[END_DATE] >= MinDate,
REMOVEFILTERS(Dates) -- Ignore any date filters for accurate calculation
)
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Please Subscribe my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Hi @Jamey
To calculate the beginning-of-year price (last valid price before the selected date range) for each vendor and material, you can use the following DAX measure:
Beginning of Year Price =
VAR MinDate = CALCULATE(MIN(Dates[Date]), ALLSELECTED(Dates))
RETURN
CALCULATE(
MAX(FCI_RAWMAT_PRICE_HIST[PRICE_AMT]),
FCI_RAWMAT_PRICE_HIST[BEG_DATE] <= MinDate,
FCI_RAWMAT_PRICE_HIST[END_DATE] >= MinDate,
REMOVEFILTERS(Dates) -- Ignore any date filters for accurate calculation
)
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Please Subscribe my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
hi @Jamey ,
could you tell more about "to see the data prior to the year and then get the LAST price based on the BEG_DATE, per vendor"?
ideally describe with examples.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |