Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I have a transaction table(A) with 4 columns say X, Y, Value and Date. I want to create a new table(B) from Table A such that Table B have unique transactions(rows) based on the combination of X and Y columns, and should pick only first transaction based on the date column. For example -
Table A:
| X | Y | Value | Date |
| X1 | Y1 | 1 | 11-11-2022 |
| X1 | Y1 | 2 | 14-11-2022 |
| X2 | Y2 | 4 | 13-11-2022 |
Table B: It should only have one row for X1 and Y1 combination for date: 11-11-2022 as it is the first trasaction.
| X | Y | Value | Date |
| X1 | Y1 | 1 | 11-11-2022 |
| X2 | Y2 | 4 | 13-11-2022 |
Thanks in advance.
Solved! Go to Solution.
Hi @mak_tushar ,
Here are the steps you can follow:
1. Create calculated column.
Table 2 =
CALENDAR(
MIN('Table'[Invoice Date]),MAX('Table'[Invoice Date]))
2. Create measure.
Flag =
var _select=SELECTEDVALUE('Table 2'[Date])
return
IF(
MAX('Table'[Invoice Date])=
MINX(FILTER(ALL('Table'),'Table'[X]=MAX('Table'[X])&&'Table'[Y]=MAX('Table'[Y])&&'Table'[Location]=MAX('Table'[Location])&&'Table'[Invoice Date]>=_select),[Invoice Date]),1,0)
3. Place [Flag]in Filters, set is=1, apply filter.
4. 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 @mak_tushar ,
Here are the steps you can follow:
1. Create calculated column.
Table 2 =
CALENDAR(
MIN('Table'[Invoice Date]),MAX('Table'[Invoice Date]))
2. Create measure.
Flag =
var _select=SELECTEDVALUE('Table 2'[Date])
return
IF(
MAX('Table'[Invoice Date])=
MINX(FILTER(ALL('Table'),'Table'[X]=MAX('Table'[X])&&'Table'[Y]=MAX('Table'[Y])&&'Table'[Location]=MAX('Table'[Location])&&'Table'[Invoice Date]>=_select),[Invoice Date]),1,0)
3. Place [Flag]in Filters, set is=1, apply filter.
4. 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
Thanks @Anonymous, worked perfectly.
This is part of the previous one. Actually Table A has data for past 3 years and I want to have data only after 1 Feb in the new table. -
Try to create a new table with the code below:
B =
ADDCOLUMNS(
SUMMARIZE (
A,
A[X],
A[Y],
A[Value]
) ,
"Date",
CALCULATE (MIN(A[Date]))
)
Is there a way to apply filter on the date as well? I want to pull records from table A that have invoice date greater than 1 feb.
is it a new requirement or in addition to the previous one?Or could you elaborate the expected table in Excel?
This is part of the previous one. Actually Table A has data for past 3 years and I want to have data only after 1 Feb in the new table. -
Then try this:
B =
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE (
A,
A[X],
A[Y],
A[Value]
) ,
"Date",
CALCULATE (MIN(A[Date]))
),
A[Date]>DATE(2022,1,1)
)
Getting duplicate rows (based on X and Y column).
how does the issue look like?
Is it an issue, considering you have different data in column Value and Date?
First two rows are duplicate as the first three coulmn values are same. Form these two(duplicate) rows, I want only the first row in my table as it has an older date.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 23 | |
| 14 | |
| 10 | |
| 6 | |
| 5 |