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?
Solved! Go to Solution.
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:
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
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:
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
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] )
User | Count |
---|---|
223 | |
81 | |
75 | |
75 | |
52 |
User | Count |
---|---|
179 | |
93 | |
83 | |
76 | |
74 |