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
sjp532
New Member

Most recent of each within filtered data

Hi all,

 

I'm having a lot of trouble trying to write a DAX query for the following data set:

 

image.png

 

I've trying to create measures to count the distinct number of SiteIDs scoring "DE", "UC", etc on their most recent visit within the filtered data. I've added in the calculated column MaxDate, which seems to successfuly show the date of the most recent visit ever to a site.

 

MaxDate = CALCULATE(MAX(Visits[Date]), FILTER(Visits, EARLIER(Visits[SiteID])=Visits[SiteID]))

 

However, if I filter to periods 1&2 then site id 203 shows the MaxDate as the max visit date ever ( which is in period 3), not the visit date in period 2 as I'd like:

 

image.png

 

Is there a way I write this to calculate the max date within the filtered data only?

 

Any help would be much appreciated as I've spent a long time trying to figure this out!

 

Many thanks,

 

Stephen

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@sjp532,

Calculate columns are computed during database processing(e.g. data refresh) and then stored in the model, they do not response to user selections on the report. Please create a measure instead and create visual as shown in the following screenshot.

 

Measure  = MAX(Visits[Date])

1.JPG

Reference:
https://community.powerbi.com/t5/Community-Knowledge-Base/Calculated-Column-Table-Change-Dynamically...

Regards,
Lydia

Community Support Team _ Lydia Zhang
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

1 REPLY 1
v-yuezhe-msft
Employee
Employee

@sjp532,

Calculate columns are computed during database processing(e.g. data refresh) and then stored in the model, they do not response to user selections on the report. Please create a measure instead and create visual as shown in the following screenshot.

 

Measure  = MAX(Visits[Date])

1.JPG

Reference:
https://community.powerbi.com/t5/Community-Knowledge-Base/Calculated-Column-Table-Change-Dynamically...

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.