Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Changing calculate column to measure help

I have a calculate column which is basically calculating max date per ID then saying if the date equals the latest date it gives me 0 or 1 then i filter my table to this, below are my currentl calculations;

 

Column = CALCULATE(MAX('Country[Date]),ALLEXCEPT('Country','Country'[ID]))
 
Column 2 = if('Countryl'[Date] = 'Country'[Column],1,0)
 
this gives me the ability to filter this table to the latest date per ID attached below;
 
At the moment this works fine, but i want to be able to see historic stuff based on someone selecting a date the chart recalculates to look at the latest date per id to let me know which country comes under the latest date. Below have attached some sample data as well that can give more context
 
 
 

 

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

Sorry for the late reply.

 

Create a measure as below:

 

Measure 2 = 
CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[Date] in FILTERS('Date table'[Date])&&'Table'[Country]=MAX('Table'[Country])))

 

And you will see:

 

v-kelly-msft_3-1614763011630.png

 

 
 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

First create a date table as below:

 

 

Date table = VALUES('Table'[Date])

 

 

Then create an index column in query editor and a measure as below:

 

 

Measure = 
var _maxdates=CALCULATETABLE(VALUES('Table'[Date]),FILTER(ALL('Table'),'Table'[ID]=MAX('Table'[ID])&&'Table'[Date]<=SELECTEDVALUE('Date table'[Date])))
var _maxdate=MAXX(_maxdates,[Date])
VAR _index=CALCULATETABLE(VALUES('Table'[Index]),FILTER(ALL('Table'),'Table'[ID]=MAX('Table'[ID])&&'Table'[Date]=_maxdate))
Return
IF(MAX('Table'[Index]) in _index,1,0)

 

 

 And you will see:

 

v-kelly-msft_1-1613111918728.png

 

 

For the related .pbix file,pls see attached.

 

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

@v-kelly-msft  thank you for coming back, i have 1 issue i am trying to display this in a bar chart so country is the axis and the value is a count of the how many Ids (based on latest date) fall into that country bracket. But can't seem to get this working 

amitchandak
Super User
Super User

@Anonymous , Not very clear.

Try a measure like

if(min('Country'[Date]), = calculate(min('Country'[Date]), ALLEXCEPT('Country','Country'[ID])),1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak thank you for coming back, i have 1 issue i am trying to display this in a bar chart so country is the axis and the value is a count of the how many Ids (based on latest date) fall into that country bracket. But can't seem to get this working.

Hi @Anonymous,

 

Sorry for the late reply.

 

Create a measure as below:

 

Measure 2 = 
CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[Date] in FILTERS('Date table'[Date])&&'Table'[Country]=MAX('Table'[Country])))

 

And you will see:

 

v-kelly-msft_3-1614763011630.png

 

 
 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.