Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello all,
I wanted to calulcate the date difference but with the filter.
I wrote the following but it doesn't work.
MEASURE = IF((max(OpportunityBase[StatusCode])=100000023), (DATEDIFF(TODAY(), FIRSTDATE('OpportunityBase'[Close By]), DAY)))
Basicallly, I want to calculate the datediff between 'Close By' and Today only if Statuscode of the Close by equals 100000023.
How can I solve this? Please help me 🙏
Solved! Go to Solution.
What are you doing with FIRSTDATE()? That is a time intelligence function.
This measure will functionally work, but I am not sure it will give you the results are are wanting. You should not use time intelligence functions to do date math. If you are using it intentionally knowing that it invokes context transition, that is fine, otherwise, use MIN() instead, or post back with more info.
Some Measure =
VAR varStartDate =
TODAY()
VAR varEndDate =
FIRSTDATE( 'OpportunityBase'[Close By] )
RETURN
IF(
MAX( OpportunityBase[StatusCode] ) = 100000023,
DATEDIFF( varStartDate, varEndDate, DAY )
)
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI Reporting
Try the following to see if it works:
Measure Name =
VAR _max = MAX( OpportunityBase[StatusCode] )
VAR _date = FIRSTNONBLANK( 'OpportunityBase'[Close By] , 1)
RETURN
IF ( _max = 100000023 ,
DATEDIFF( TODAY(), _date , DAY ) ,
BLANK()
)
Try the following to see if it works:
Measure Name =
VAR _max = MAX( OpportunityBase[StatusCode] )
VAR _date = FIRSTNONBLANK( 'OpportunityBase'[Close By] , 1)
RETURN
IF ( _max = 100000023 ,
DATEDIFF( TODAY(), _date , DAY ) ,
BLANK()
)
Omggg. It totally worked! Thank you soo much! ❤️
What are you doing with FIRSTDATE()? That is a time intelligence function.
This measure will functionally work, but I am not sure it will give you the results are are wanting. You should not use time intelligence functions to do date math. If you are using it intentionally knowing that it invokes context transition, that is fine, otherwise, use MIN() instead, or post back with more info.
Some Measure =
VAR varStartDate =
TODAY()
VAR varEndDate =
FIRSTDATE( 'OpportunityBase'[Close By] )
RETURN
IF(
MAX( OpportunityBase[StatusCode] ) = 100000023,
DATEDIFF( varStartDate, varEndDate, DAY )
)
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingAnd it worked too! Thank you so much! I appreciate it! ❤️
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
9 | |
8 | |
6 | |
6 | |
6 |