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
3,232 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,149 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, 2024 in Power BI by Evanjalin
• 20,980 points
175 views
0 votes
1 answer

How can I create a function in Power Query that processes data differently based on a user-selected parameter?

The following steps outline the creation of ...READ MORE

answered 5 days ago in Power BI by anonymous
• 20,980 points
74 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,731 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,995 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,768 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,541 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,462 views
0 votes
4 answers

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

R|ight click on the table you want ...READ MORE

answered Nov 18, 2022 in Power BI by Madelein Tolmay
79,614 views
0 votes
1 answer

Calculate GB Using DAX in Power BI

Hi, @Vnk You can go through this regarding ...READ MORE

answered Jun 30, 2020 in Power BI by Gitika
• 65,770 points
5,006 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