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 power Bi community
I want to make a table that shows how often an assignment is reopended.
I get the information from a freetext colum (unfortunately).
Where I have tried to make a lot of logic in PowerQuery to make it fit.
One of my problems is that they have made an interval where they write x (a number) months.
I have made a table where I can see the first date, the interval in months (x) and all the dates in the next three years where I try to see if this matches the selected dates.
Example: if the first date is the first of january 2024 and x months = 2 than the the correct dates would be
first of january 2024, first of marts 2024 first of may 2024 first of July 2024 and so forth
To do this I have made a table with
[FirstDate] = the first day the assingment start
[Date] = a colum with all dates the next three years
[interval] = the number of months between each time the assignment should be completed.
[True] = a new (true/false) colum I want to make where I see if the date = firstdate + one or more intervals of months
I tried to solved it with this line:
Date.AddMonths([FirstDate],Number.RoundUp((Duration.Days([Date]-[FirstDate])/30)/[interval])*[interval])
My problem is that not all months have 30 days. So overtime it stops working. I have tried to change the 30 to 31 and 30.5 and it helps, but it is still not ideal.
I think I need to calculate exactly how many months have passed with a formel or change the formel so it looks at days instead of months, but I am not quite sure.
All help will be greatly appreciated.
Solved! Go to Solution.
Ok I found a solution, but it requires a diffrent approach.
First I check if the date of the months are the same in the two columns.
= if Date.Day([Date]) = Date.Day([FirstDate]) then
Number.Round(Number.From(([Date] - [FirstDate])/( 365.25 / 12 )) ,0 )/[Number]
else 0)
I then make a new colum where I changes all rows containing a "," to 0 as well.
At the end I can just check if the value is > 0.
I have the solution now so a moderator can just close this thread.
Ok I found a solution, but it requires a diffrent approach.
First I check if the date of the months are the same in the two columns.
= if Date.Day([Date]) = Date.Day([FirstDate]) then
Number.Round(Number.From(([Date] - [FirstDate])/( 365.25 / 12 )) ,0 )/[Number]
else 0)
I then make a new colum where I changes all rows containing a "," to 0 as well.
At the end I can just check if the value is > 0.
I have the solution now so a moderator can just close this thread.
All that you need to do is mark the reply to the post as a solution to mark as closed.
Hey @watkinnc
I tried that but I don't know how to use the [DateColumn] in this case.
If I just use my DateColumn it will divide all months by 30 or 31 depending on the choosen date the selected months.
So if the date column in a specific row is in August and looking 3 months back it will divide with 31*3 where it really should only divide with (31+30+31).
You can replace "30" with
Date.DaysInMonth([DateColumn])
--Nate
Please provide your work-in-progress Power BI Desktop file (with sensitive information removed) that covers your issue or question completely in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.
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.