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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
cottrera
Post Prodigy
Post Prodigy

DAX column measure 1 for max date else 0

Hi 

 

I have a table with lots of property references that apear multiple times but with different dates. I would like to create a calculated column that returns 1 for the max date relating to each of these references els return 0

 

RefDateDAX - Max Date
13233216/06/20110
13233218/01/20140
13233210/11/20150
13233224/04/20170
13233203/04/20200
13233211/05/20201
9000016/06/20110
9000018/01/20140
9000010/11/20150
9000024/04/20170
9000003/04/20200
9000011/05/20211

 

thank you

RIchard

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @cottrera ,

 

try the following calculated column. I added some explanation in the code:

 

 

MaxDate =
-- Calculate the MAX date for the current REF-ID
VAR vMaxDate = CALCULATE ( MAX ( myTable[Date] ), ALLEXCEPT ( myTable, myTable[Ref] ) )
RETURN
    -- When the date of the current row is equal to the vMaxDate then return 1 otherwise 0
    IF (
        myTable[Date] = vMaxDate,
        1,
        0
    )

 

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

3 REPLIES 3
cottrera
Post Prodigy
Post Prodigy

Appologies Denis my data model was Direct Query. When I changed it to Import your measure worked fine 😁

cottrera
Post Prodigy
Post Prodigy

Hi Denis thank you for your quick reponse. I am getting these errors when adding the code to a column measure

cottrera_0-1632132972253.png

Richard

selimovd
Super User
Super User

Hey @cottrera ,

 

try the following calculated column. I added some explanation in the code:

 

 

MaxDate =
-- Calculate the MAX date for the current REF-ID
VAR vMaxDate = CALCULATE ( MAX ( myTable[Date] ), ALLEXCEPT ( myTable, myTable[Ref] ) )
RETURN
    -- When the date of the current row is equal to the vMaxDate then return 1 otherwise 0
    IF (
        myTable[Date] = vMaxDate,
        1,
        0
    )

 

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors