Forum Discussion
Creating future dates with values in new table
- Anonymous1 year ago
Hi Tendo,
The error (The 'Price' object of type Column already exists) you're seeing happens because the column Price already exists in your base table (Subscription line table), and the DAX formula tries to add another column with the same name using ADDCOLUMNS.
To fix this, you'll just need to rename the new column in the ADDCOLUMNS function to something like "Billing Price" (or any other unique name). Here's the updated code:
NextBillingSchedule =
VAR MaxYears = 10
RETURN
ADDCOLUMNS (
GENERATE (
FILTER (
'Subscription line table',
NOT ISBLANK ( [FutureBillingDate] )
),
VAR CustomerName = RELATED ( 'Customer Subscription contract table'[Customer] )
VAR ContractNumber = 'Subscription line table'[Subscription Contract number]
VAR PriceValue = 'Subscription line table'[Price]
VAR StartDate = [FutureBillingDate]
VAR EndDate = 'Subscription line table'[End Date]
VAR Frequency = 'Subscription line table'[Payment frequency]
VAR MaxDate = MIN ( EndDate, EDATE ( StartDate, 12 * MaxYears ) )
RETURN
ADDCOLUMNS (
GENERATESERIES ( 0, MaxYears * 12, 1 ),
"Customer", CustomerName,
"Subscription Contract number", ContractNumber,
"Next Billing Date",
SWITCH (
TRUE (),
Frequency = "Yearly", DATEADD ( StartDate, [Value], YEAR ),
Frequency = "Monthly", DATEADD ( StartDate, [Value], MONTH ),
BLANK()
),
"Billing Price", PriceValue // Renamed to avoid collision
)
),
"BillingDateFiltered",
IF ( [Next Billing Date] <= 'Subscription line table'[End Date], [Next Billing Date], BLANK() )
)Best Regards,
Hammad.
Hello Anonymous ,
unfortunately I am receiving the following failure:
The āPriceā object of type Column already exists in the Next billing object of type table. (itĀ“s translated from german, so i donĀ“t know if failure is in english called the same)
Do you have an idea how to solve the issue?
Thank you
Tendo
Hi Tendo,
The error (The 'Price' object of type Column already exists) you're seeing happens because the column Price already exists in your base table (Subscription line table), and the DAX formula tries to add another column with the same name using ADDCOLUMNS.
To fix this, you'll just need to rename the new column in the ADDCOLUMNS function to something like "Billing Price" (or any other unique name). Here's the updated code:
NextBillingSchedule =
VAR MaxYears = 10
RETURN
ADDCOLUMNS (
GENERATE (
FILTER (
'Subscription line table',
NOT ISBLANK ( [FutureBillingDate] )
),
VAR CustomerName = RELATED ( 'Customer Subscription contract table'[Customer] )
VAR ContractNumber = 'Subscription line table'[Subscription Contract number]
VAR PriceValue = 'Subscription line table'[Price]
VAR StartDate = [FutureBillingDate]
VAR EndDate = 'Subscription line table'[End Date]
VAR Frequency = 'Subscription line table'[Payment frequency]
VAR MaxDate = MIN ( EndDate, EDATE ( StartDate, 12 * MaxYears ) )
RETURN
ADDCOLUMNS (
GENERATESERIES ( 0, MaxYears * 12, 1 ),
"Customer", CustomerName,
"Subscription Contract number", ContractNumber,
"Next Billing Date",
SWITCH (
TRUE (),
Frequency = "Yearly", DATEADD ( StartDate, [Value], YEAR ),
Frequency = "Monthly", DATEADD ( StartDate, [Value], MONTH ),
BLANK()
),
"Billing Price", PriceValue // Renamed to avoid collision
)
),
"BillingDateFiltered",
IF ( [Next Billing Date] <= 'Subscription line table'[End Date], [Next Billing Date], BLANK() )
)
Best Regards,
Hammad.