Forum Discussion
Merge not pulling through correct information
- 5 years ago
Hi, Krisso1975
Based on your description, I assume that you want to create a custom column based on date column. I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create a custom column with the following m codes.
let start = Date.AddDays( Date.EndOfMonth( Date.AddMonths([Date],-1)),1), end = Date.EndOfMonth([Date]), today = Date.From(DateTime.LocalNow()) in if today<start then "Next" else if today>end then "Previous" else if today>=start and today<=end then "Current" else nullResult:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi HotChilli
Thank you for the help
This is the screen I have put the formula in to show current period
And the other table merges on Month End Date but is showing previous still even though the above is showing current
Thanks for your help
The first thing which is odd is that the datatype on the first Current Period screen is set to 'any', it should be text.
I would like to see the screen from the Merge step - the one where you pick the 2 tables and the join types please.
- Krisso19755 years agoRegular Visitor
I assume you mean this step
- HotChilli5 years agoCommunity Champion
That's the screen.
I see that the tables join on PeriodEndDate and MonthEndDate and so we're looking for a MonthEndDate of 30/04/2021 in the splitBills table (if I've got that right) to bring back "Current".
Do we have that?
- Krisso19755 years agoRegular Visitor
I thought (wrongly) im guessing the merge step would acheive that on the above. You are correct on the return in the split bills table
To give you more context at what I am trying to acheive this is a screen grab of my excel version
So far I have easily created the annual and monthly targets and have pulled through accurate data for the years billing. I am now trying to acheive the current month data and then try and do the other calculations. If that makes sense