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
M_SBS_6
Helper V
Helper V

Convert DAX to M

Hi, I have a calculated column that I have created using the DAX syntax below. This works as expected but I'd really like to have this column created in power query but I'm really struggling with the correct syntax. Would anyone be able to re-write this for me using the custom column option please? 

The column is looking for the customers earliest sub date across all their rows of data associated to the ID. 
Example output. As you can see, the new column has output the same value across all IDs as that's the customers earliest sub date. 

ID.    Subdate.       Earliest Sub Date

123. 01/01/2014.   01/01/2014

123 01/09/2014.    01/01/2014

123. 01/10/2016.    01/01/2024

123 01/12/2024.     01/01/2024

 

Earliest sub date =
Var earliestdate =
Calculate(
Min(sp[subdate]),
Filter (sp,sp[id] = earlier (sp[id])))

 

Var earliestsubdate =
Calculate(
Max(sp[subdate]),
Filter (

sp,

sp[id] = earlier (sp[id]) &&
Sp[sub] = earliestdate ))

 

Return earliestclosedate

6 REPLIES 6
v-sdhruv
Community Support
Community Support

Hi @M_SBS_6 ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @M_SBS_6 ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @M_SBS_6 ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @M_SBS_6 ,
You can try these in Power query-

1. Group By Id (Choose Advanced)
2. 1st consider all rows
3. In 2nd grouping, add min Sub date

Shruti_D_0-1744538648065.png

This will give you all the rows with along with sub date and its corresponding Earliest Sub date.

Hope this helps!
If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.

ryan_mayu
Super User
Super User

@M_SBS_6 

could you pls clarify the logic? I think the DAX you provided does not work in PBI.





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

Proud to be a Super User!




Greg_Deckler
Community Champion
Community Champion

@M_SBS_6 Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.