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
Milan6687
Helper II
Helper II

Create custom column using max and filter

Hi,

 

I have a table like below:

Id     Name   Type Date

100   Apple    fruit   12/01/2020

100   Apple     sweet 15/01/2020

 

I want to create the report where Type =fruit and one date column new_date=max(Date) where Type=sweet

 

Id Name Type New_Date

100 Apple fruit  15/01/2020

 

I tried many options but failed to to get desird result.

 

Thanks,

Milan

 

  

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Create new table,

Table 2 = SUMMARIZE('Table','Table'[ID],'Table'[Name],'Table'[Type],"New_date",CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[ID]),'Table'[Type]="Sweet"))
 
Or if you want to do by previous method then
create measure as below
Measure = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[ID]),'Table'[Type]="Sweet")
 
and filtet out type.
 
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.
 

View solution in original post

Anonymous
Not applicable

New Column = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[ID]),'Table'[Type]="Sweet")
 
 and filter out type.
 
Thanks,
Pravin
 
If I resolve your problem Mark it as a solution and give kudos.

View solution in original post

9 REPLIES 9
Milan6687
Helper II
Helper II

Hi,

Actually i gave you incomplete data. My apology.

Data looks like:

ID Name Type Date

100 apple  fruit 01/01/2020

100 apple  sweet 02/02/2020

200  banana fruit 03/03/2020

200 banana sweet 04/04/2020

 

Expected output

ID Name new_Date

100 apple 02/02/2020

200 banana 04/04/2020

 

filter: Type=fruit

New_date logic= Max(date) where type=sweet

 

I tried:

CALCULATE(MAX(Table(date),FILTER(Table,table[type]="sweet"))

but it gave me

ID Name new_Date

100 apple 04/04/2020

200 banana 04/04/2020

 

I think I need to put GROUPBY but exactly how and where its where i am struggling.

 

Thanks,

Milan

 

 

You are taking the max of the date on fruit, then why type filter.

Min of type and max of date will work as long as view/group by is fruit.

 

Anonymous
Not applicable

Create new table,

Table 2 = SUMMARIZE('Table','Table'[ID],'Table'[Name],'Table'[Type],"New_date",CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[ID]),'Table'[Type]="Sweet"))
 
Or if you want to do by previous method then
create measure as below
Measure = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[ID]),'Table'[Type]="Sweet")
 
and filtet out type.
 
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.
 

Thanku 2nd option worked for me.

 

Thanks,

Milan

Anonymous
Not applicable

New table=Summerize(filter(table,table[type]="Sweet"),table[id],Table[Name],Table[Type],"New_Date",MAx(Table[Date]))

 

Thanks,

Pravin

www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Hi,

 

Actually I don't want to create new table. Can it be done using create new column on the same table.

 

Appriciate your help.

 

Thanks,

Milan

Anonymous
Not applicable

New Column = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[ID]),'Table'[Type]="Sweet")
 
 and filter out type.
 
Thanks,
Pravin
 
If I resolve your problem Mark it as a solution and give kudos.
amitchandak
Super User
Super User

Take Min of Type and Max of Fruit in Visual or create a new table like

new table = summarize(table,table[Id],table[Name],"_Type",Min(Type),"_date",Max(Date))

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

Anonymous
Not applicable

Create one measure

Measure= Calculate(Max(table[Date],all(table)

 

Then drag id,name,type,measure in table visual and go to visual level filter and set type is fruit.

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

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.