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 have a sales table with 2 main columns:
Price - How much was sold the product
Installments - How many installments was splitted the payment (in months)
I'm trying to build a third column with the information of how much cash will get in over this year. For instance, if someone bought a product for $400 on november and splitted the payment in 4 times, this year I'll get $100 and next year I'll get the other $300, so the column should return "$100". How can I build that?
Solved! Go to Solution.
Hi @Anonymous ,
See below the difference between the content in the formula bar and the Custom Column's text box.
I also attach the PBIX file for your reference.
Hello @mpoppes,
I agree with @mahoneypat and would go for a DAX measure here, but since you posted the question in PQ forum this is an alternative approach using the Editor and considering you had sale dates in different years.
= Table.AddColumn(#"Changed Type", "Current Year's Receipts", each ([Price]/[Monthly Installments])*List.Count(List.Select(List.Transform({0..[Monthly Installments]-1}, (x) => Date.AddMonths([Date],x)),each Date.IsInCurrentYear(_))),Currency.Type)
Hello @Anonymous,
I agree with @mahoneypat and would go for a DAX measure here, but since you posted the question in PQ forum this is an alternative approach using the Editor and considering you had sale dates in different years.
= Table.AddColumn(#"Changed Type", "Current Year's Receipts", each ([Price]/[Monthly Installments])*List.Count(List.Select(List.Transform({0..[Monthly Installments]-1}, (x) => Date.AddMonths([Date],x)),each Date.IsInCurrentYear(_))),Currency.Type)
Thanks for the concern, I'll think about that.
I tried the formula you sent, but i got an Expression Error, saying that "Changed Type" wasn't recognized. How can I fix it?
Hi again @Anonymous,
Please remove the string of code shown below from your "Fórmula de coluna personalizada" Text Box.
Table.AddColumn(#"Changed Type", "Current Year's Receipts", each
This piece of code will be added by PQ once you click "Ok" with a reference to the immediate previous step in you query instead of #"Changed Type" and the name of your Custom Column instead of "Current Year's receipts".
I hope this helps.
Sorry, I still don't get it. Was it supossed to me delete the first part, like the print bellow?
I'm not that used to the PQ language
Hi @Anonymous ,
See below the difference between the content in the formula bar and the Custom Column's text box.
I also attach the PBIX file for your reference.
Here is a column expression that should do that. Replace T2 with your actual table name (fix column names too). FYI that you could also do this as a measure and avoid storing this extra column.
ValueThisYear =
VAR thisdate = T2[SaleDate]
VAR monthsthisyear =
DATEDIFF ( thisdate, DATE ( YEAR ( thisdate ), 12, 31 ), MONTH )
RETURN
T2[SalePrice] * monthsthisyear / T2[Installments]
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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.