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.
Hi,
I'm trying to join a date table to itself using a >= operator. The date table contains Period End Dates, and contains only a single column, which is the DateKey in integer format (ex: 20190131). The combined date table should contain two columns. The first column is the original DateKey, and the second column is each DateKey that is >= the original date key. Ex: Let's say the table contains three Period End Dates: 20190131, 20181231, and 20181130. The combined date table would look like this:
DateKey1 DateKey2
20190131 20190131
20190131 20181231
20190131 20181130
20181231 20181231
20181231 20181130
20181130 20181130
If they were two separate date tables, I could use a GENERATE statement to achieve the result. This works:
GENERATE(DateTable1, SUMMARIZE(FILTER(DateTable2,DateTable2[DateKey] <= DateTable1[DateKey]),DateTable2[DateKey]))
However, if I just reference DateTable1, I get an error that the GENERATE does not allow two columns with the same name:
GENERATE(DateTable1, SUMMARIZE(FILTER(DateTable1,DateTable1[DateKey] <= DateTable1[DateKey]),DateTable1[DateKey]))
I'm looking for suggestions about how to code this statement without needing two versions of the table.
Thanks for any help.
Solved! Go to Solution.
Hello @Anonymous
try this:
Table = GENERATE( Data, SELECTCOLUMNS( CALCULATETABLE( VALUES( Data[DateKey] ), Data[DateKey] >= EARLIER( Data[DateKey] ) ), "DateKey2", Data[DateKey] ) )
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
Hello @Anonymous
try this:
Table = GENERATE( Data, SELECTCOLUMNS( CALCULATETABLE( VALUES( Data[DateKey] ), Data[DateKey] >= EARLIER( Data[DateKey] ) ), "DateKey2", Data[DateKey] ) )
Did I answer your question correctly? Mark my answer as a solution!
Proud to be a Datanaut!
Thank you - that worked
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
95 | |
77 | |
65 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |