Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
Hi DAX Experts,
I'm kind of struggling to achieve a result using dax.
Formula's used to achieve:
MaxDate = var maxselected=CALCULATE(MAX('Date'[Date]))return if(ISFILTERED('Date'[Year]),maxselected)
Ageing is := DATEDIFF(Sheet1[ShortCreatedDate],[MaxDate],DAY)
AverageAge: AvgAge = AVERAGE(Sheet1[ageing])
Requirement it to calculate the average age of ticket, but based on slicer selection.
1.If a year is seleted the ageing should be calculated as difference of created date and the last date available month of the selected year.
2.If a year & Quarter is seleted the ageing should be calculated as difference of created date and the last date available month of the selected quarter for that particular year.
3.If a year & Quarter & Month is seleted the ageing should be calculated as difference of created date and the last date available month of the selected month for that particular year & Quarter.
As part of my Trial to achieve the same i have used max date measure which i feel is giving the last date based on th selected slicer.
The part where i'm getting confused is when i use the measure to find the ageing I'm getting Blank as value.
Can someone please point me in the right direction to get the desired value.
Have also attached the screen shot & PBIX file in the below link.
https://drive.google.com/file/d/1quH8cDAUpESthO6qx09Bji6whWn6M7fq/view?usp=sharing
Solved! Go to Solution.
@PBI_Publisher , As long as a month, qtr are selected from date table it will be taken care.
You need to take care of row context
measure =
var _max = MAXX(allselected('Date'),'Date'[Date])
return DATEDIFF(max(Sheet1[ShortCreatedDate]),_max,DAY)
for row context refer
@PBI_Publisher , As long as a month, qtr are selected from date table it will be taken care.
You need to take care of row context
measure =
var _max = MAXX(allselected('Date'),'Date'[Date])
return DATEDIFF(max(Sheet1[ShortCreatedDate]),_max,DAY)
for row context refer
Hi @amitchandak ,
The last idea which u suggested worked for me. Adding to that i have a requirement where after finding the difference of between the dates. I need to put the value into a calculated colum/Measure where it will be grouped in the below format based on the days difference of 2 dates i need to make a bucket. (0-3 days, 4-7 days... like this).
Can You please help me in achieveing this.
I think i'm missing something silly here i tried achieveing it but it always shows me difference from current day not from the selected month last day. What could be the problem here? Can someone please guide me.
Thnaks in advance.
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 |
---|---|
10 | |
10 | |
10 | |
9 | |
7 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
10 |