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.
HI Anonymous ,
I apologize that I have not yet replied. I'm very busy at the moment and had to postpone this topic. I'll take a look at your proposed solution as soon as possible and give you some feedback.
Thank you for your help and best regards
Tendo
- Anonymous1 year agoNot applicable
Hi Tendo,
Thank you for coming back and confirming, please get back to us when you have further update on this issue.
Best Regards,
Hammad.
- Anonymous1 year agoNot applicable
Hi Tendo,
Hope everything’s going smoothly on your end. We haven’t heard back from you, so I wanted to check if the issue got sorted. If yes, marking the helpful solution would be awesome for others who might run into the same thing.
Still stuck? No worries just drop us a message and we can jump back in on the issue.Best Regards,
Hammad.
- Anonymous1 year agoNot applicable
Hi Tendo,
We noticed there hasn’t been any recent activity on this thread, so I wanted to check if you got a chance to look into the response provided earlier or if the issue got resolved from your end.If you still need support, just reply here and we’ll pick it up from where we left off.
Best Regards,
Hammad.