DAX EARLIER function in Power Query

0 votes

I have a table with lots of different dates in column DATE and a smaller number of letters in column LETTER. I now want the maximum date for each letter.

In DAX, I would use something like 

CALCULATE(MAX([Date]),FILTER(ALL(Table),[Letter]=EARLIER([Letter])).

Is there an equivalent to EARLIER in M/Power Query?

Oct 1, 2020 in Power BI by anonymous
• 10,480 points
2,958 views

1 answer to this question.

0 votes

Solutions in the code below. Notice that each uses "PreviousStep" as a basis, so these are separate solutions.

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    PreviousStep = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Letter", type text}}),

    // 1. Add a column to the original table with the MaxDate for each letter
    //    "earlier"  is just the name of a function parameter; it could as well have been "x" or "MarcelBeug"
    AddedMaxDate = Table.AddColumn(PreviousStep, "MaxDate", (earlier) => List.Max(Table.SelectRows(PreviousStep, each [Letter] = earlier[Letter])[Date])),

    // 2. Group by letter and get the MaxDate for each letter
    GroupedOnLetter = Table.Group(PreviousStep, {"Letter"}, {{"MaxDate", each List.Max([Date]), type date}})
in
    GroupedOnLetter
answered Oct 1, 2020 by Gitika
• 65,770 points

Related Questions In Power BI

0 votes
1 answer

Dax query in power bi

Here is my table before I have ...READ MORE

answered Oct 22, 2018 in Power BI by Hannah
• 18,520 points
1,075 views
0 votes
0 answers

What are your best practices for managing code modularity and reusability in Power Query and DAX?

What are your best practices for managing ...READ MORE

Oct 30 in Power BI by Evanjalin
• 7,890 points
63 views
0 votes
1 answer

list reports with calculated percentage in Power BI using dax

Create a Measure called Total Revenue: Total Revenue = SUMX( ...READ MORE

answered Oct 22, 2018 in Power BI by Hannah
• 18,520 points
1,653 views
0 votes
1 answer

Power Query Web request results in “CR must be followed by LF” Error

What I think is, it might look ...READ MORE

answered Oct 29, 2018 in Power BI by Shubham
• 13,490 points
1,903 views
0 votes
1 answer

Using DAX calculation how to calculate monthly budget till today in power bi Desktop?

You can make use of this: MTD Budget ...READ MORE

answered Sep 24, 2020 in Power BI by Gitika
• 65,770 points
1,860 views
0 votes
1 answer

Understanding the DAX CALCULATE function

Using the CALCULATE function makes the DAX perform a context ...READ MORE

answered Sep 28, 2020 in Power BI by Gitika
• 65,770 points
1,618 views
0 votes
1 answer

DAX / PowerPivot query functions to spread aggregated values over time period

The solution below assumes a table called ...READ MORE

answered Oct 5, 2020 in Power BI by Gitika
• 65,770 points
1,353 views
0 votes
1 answer

DAX Userelationship function

 You need a way for the measure ...READ MORE

answered Oct 5, 2020 in Power BI by Gitika
• 65,770 points
1,217 views
+2 votes
3 answers

How to replace null values with custom values in Power BI(power query editor)?

Hi Nithin, To fill or replace the null or ...READ MORE

answered Mar 8, 2019 in Power BI by Cherukuri
• 33,030 points
160,240 views
0 votes
3 answers

How to add an extra column to the existing table in power bi query editor?

Click on edit queries after loading source ...READ MORE

answered Dec 16, 2020 in Power BI by Roshni
• 10,480 points
79,085 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP