Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
dolevh
Helper II
Helper II

create a new table with min date of price column

Hi all, 

 

I have this table:  

 

Table Name: Customers

   ID   Date   Price
   123   1/1/2021  Blank
   123   2/1/2021  0
   123   3/1/2021  100
   123   4/1/2021  200
   321   1/1/2021  99,999,999
   321   2/1/2021  50
   45678   1/1/2021  Blank
   45678   2/1/2021  0
   45678   3/1/2021  1,000

 

and now, I want to create a new table that shows me just the unique ID with the first price that is greater than 0 and less than 2M.

 

Table Name: CustomersUniqueValue

   ID   Date   Price
   123   3/1/2021   100
   321   2/1/2021   50
   45678   3/1/2021   1,000

 

how can I create just the column Price with the Min Date that the first price is greater than 0 and less than 2M?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @dolevh ,

Here are the steps you can follow:

1. Create calculated column.

Flag =
    MINX(FILTER(ALL('Table'),
'Table'[ID]=EARLIER('Table'[ID])&&
'Table'[Price] >0&&
'Table'[Price]<200&&
'Table'[Price]<>BLANK()),[Price])
Flag1 =
IF(
    'Table'[Date]=
MAXX(FILTER(ALL('Table'),'Table'[Flag]<>BLANK()&&
'Table'[Flag]='Table'[Price]&&'Table'[ID]=EARLIER('Table'[ID])),[Date]),1,0)

2. Create calculated table.

Table2 =
var _table1=
FILTER(ALL('Table'),'Table'[Flag1]=1)
return
SUMMARIZE(
    _table1,
    [ID],[Date],[Price])

3. Result:

vyangliumsft_0-1656304059513.png

 

Best Regards,

Liu Yang

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

3 REPLIES 3
Anonymous
Not applicable

Hi  @dolevh ,

Here are the steps you can follow:

1. Create calculated column.

Flag =
    MINX(FILTER(ALL('Table'),
'Table'[ID]=EARLIER('Table'[ID])&&
'Table'[Price] >0&&
'Table'[Price]<200&&
'Table'[Price]<>BLANK()),[Price])
Flag1 =
IF(
    'Table'[Date]=
MAXX(FILTER(ALL('Table'),'Table'[Flag]<>BLANK()&&
'Table'[Flag]='Table'[Price]&&'Table'[ID]=EARLIER('Table'[ID])),[Date]),1,0)

2. Create calculated table.

Table2 =
var _table1=
FILTER(ALL('Table'),'Table'[Flag1]=1)
return
SUMMARIZE(
    _table1,
    [ID],[Date],[Price])

3. Result:

vyangliumsft_0-1656304059513.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

dolevh
Helper II
Helper II

Hi All, 

 

Someone know how can I create just the column Price with the Min Date that the first price is greater than 0 and less than 2M? 

 

Thanks again!

Maybe try this for your calculated table.  It might not be the most efficient depending on the size of your Customers table (both columns and rows) since it is being copied temporarily.  It's not how I'd usually attempt this but it seemed like the easiest.

 

Anyone...  Please let me know if this is a bad practice since I'm pretty new at this.

 

 

FirstPrices =
VAR _Table1 =
FILTER ( Customers, Customers[Price] > 0 && Customers[Price] < 2000000 )
VAR _Table2 =
ADDCOLUMNS (
_Table1,
"MinDate", CALCULATE ( MINX ( FILTER ( _Table1, [ID] = MAX ( Customers[ID] ) ), [Date] ) )
)
VAR _Table3 =
FILTER ( _Table2, [Date] = [MinDate] )
RETURN
SELECTCOLUMNS ( _Table3, "ID", [ID], "MinDate", [MinDate], "Price", [Price] )

 

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.