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
Fátima
Helper II
Helper II

Measure that calculates a column depending on date filter

Hi!

 

I have a table similar to this:

TABLE1

ID   CENTER_ID   DATE

1     1                  12/03/2022

2     1                  13/03/2022

3     2                  12/03/2022

4     3                  12/03/2022

5     3                  13/03/2022

 

I needed to check which are the "active" records of each center, these would be the ones with the latest date, so I created a calculated column like this:

 

DAX:

isActive=
var _filter=FILTER(TABLA1,[CENTER_ID]=EARLIER('TABLA1'[CENTER_ID]))
return if([DATE]=MAXX(_filter,[DATE]),TRUE(),FALSE())
 
It gives me this result:

TABLE1

ID   CENTER_ID   DATE               isActive

1     1                  12/03/2022     FALSE

2     1                  14/03/2022     TRUE

3     2                  11/03/2022     TRUE

4     3                  12/03/2022     FALSE

5     3                  13/03/2022     TRUE

 

The problem I'm having is that I need it to be filtered on my report by a date filter. So if for example I set the filter to the records that have been created before 12/03/2022, I get:

 

TABLE1

ID   CENTER_ID   DATE               isActive

1     1                  12/03/2022     FALSE

3     2                  11/03/2022     TRUE

4     3                  12/03/2022     FALSE

 

But I would like to get:

TABLE1

ID   CENTER_ID   DATE               isActive

1     1                  12/03/2022     TRUE

3     2                  11/03/2022     TRUE

4     3                  12/03/2022     TRUE

 

Because those records where the active ones on that date.

 

How could I do this? With a measure, I guess?

 

Thanks, regards!

1 ACCEPTED SOLUTION
2 REPLIES 2

Thank you for the tutorials @amitchandak ! I got what I needed!

If you don't mind, I have another question related to this.

I created both measures, so now I can show how many active forms are on a specific date.

 

Is it possible to filter a chart by the first measure? The one that shows the last record of each CENTER_ID in my case? I'll tell you an example. I have this bar chart that shows results taken from other table, but only based on the active records. Before, when I had the calculated column (isActive), I had a filter in the filter section with isActive=TRUE checked.

 

Captura de pantalla 2023-01-25 181906.jpg

How can I filter them now, with this new measure?

 

Regards!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.