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.
I have 2 parameters where I get the 'Valuation Year' and 'Valuation Month'
I want to use these 2 parameters to add custom Column:
This is my code: I want to get the difference in month:
Number.RoundUp(Duration.Days(Date(ValuationYear,ValuationMonth,31)-[StartDate])/30)
However Date wasn't recognized.
Is there any other way to get it?
StartDate is in Date format.
Solved! Go to Solution.
If only year/month is relevant, then you can use the following code, in which <PreviousStep> is the name of the previous step in your query.
= Table.AddColumn(<PreviousStep>, "Months", each 12*(ValuationYear-Date.Year([StartDate]))+ValuationMonth-Date.Month([StartDate]))
It looks like you want to use #date, however, #date won't accept 31 for months with less than 31 days.
Also dividing by30 doesn't look like a good idea to me.
Can you specify exactly how you need the number of months to be calculated?
E.g:
April 30 to May 1 is 0 or 1 month?
April 15 to May 14 is 0 or 1 month?
April 1 to May 31 is 1 month (or 2)?
If only year/month is relevant, then you can use the following code, in which <PreviousStep> is the name of the previous step in your query.
= Table.AddColumn(<PreviousStep>, "Months", each 12*(ValuationYear-Date.Year([StartDate]))+ValuationMonth-Date.Month([StartDate]))
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 |
---|---|
114 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |