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
VWRdata
Frequent Visitor

Get Max Date of 2 Columns

I'm trying to get the Max date for each store and UPC. I managed to get the max date by store with: Measure 2 = CALCULATE ( MAX ( Distribution[Call Date] ), ALLEXCEPT ( Distribution, distribution[StoreNameEN] ) ) but then I need it by UPC as well.  

 

So, the Max date for IGA#0410-BEAUPORT / 626027730029 would be 04/06/2018 and for IGA#0410-BEAUPORT / 626027730000 would be 07/05/2018. 

 

What is the formula to do this?

 

StoreNameENUPCUnitCall Date
IGA#0410-BEAUPORT62602773002904/06/2018
IGA#0410-BEAUPORT62602773002931/05/2018
IGA#0410-BEAUPORT62602773000002/05/2018
IGA#0410-BEAUPORT62602773000007/05/2018
IGA#0410-BEAUPORT62602773002929/05/2018
SUPERC#5941-VAUDREUIL62602773002918/06/2018
IGA#8507-CONTRECOEUR62602773002922/05/2018
IGA#0294-MONTREAL62602773002904/06/2018
METRO#22635-QUÉBEC62602773002914/06/2018
IGA#8096-DUBERGER62602773002917/05/2018
METRO#1022-REPENTIGNY62602773002907/05/2018
1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @VWRdata,

 

You also could have a try with the formula below.

 

Measure =
CALCULATE (
    MAX ( 'Table1'[Call Date] ),
    FILTER (
        ALL ( 'Table1' ),
        'Table1'[StoreNameEN] = MAX ( 'Table1'[StoreNameEN] )
            && 'Table1'[UPCUnit] = MAX ( 'Table1'[UPCUnit] )
    )
)

If you have solved your problem, please accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

If you still need help, please feel free to ask.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
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

4 REPLIES 4
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @VWRdata,

 

You also could have a try with the formula below.

 

Measure =
CALCULATE (
    MAX ( 'Table1'[Call Date] ),
    FILTER (
        ALL ( 'Table1' ),
        'Table1'[StoreNameEN] = MAX ( 'Table1'[StoreNameEN] )
            && 'Table1'[UPCUnit] = MAX ( 'Table1'[UPCUnit] )
    )
)

If you have solved your problem, please accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

If you still need help, please feel free to ask.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi

 

You can give a try to this. However, would like to learn from @Greg_Deckler that whether this is efficient approach.

I know this is calculated column, not a measure though ( known dis advantage 🙂 )

 

CALCULATE ( MAX(Table1[Call_date]), 
            FILTER( Table1,Table1[Store_Name] = EARLIER(Table1[Store_Name])),
            FILTER( Table1,Table1[UPC] = EARLIER(Table1[UPC]))
)

 

Thanks

Raj

Greg_Deckler
Super User
Super User

If you really need a true mult-column aggregation, you can use my Quick Measure "MC Aggregations". 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Multi-Column-Aggregations-MC-Aggregations/m-...

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Seward12533
Solution Sage
Solution Sage

The simple measure

Max_Date  = MAX(Distribution[Call Date]) 

should work and then when you use it in a chart/table powerbi will apply the right filter context when calculating. 

 

 

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.