Forum Discussion
Dates mess
- 7 years ago
Anonymous
Adding a relationship between tables and creating calculations using those relationships will solve this issue. Here is a group of relationship blogs to help.
https://powerpivotpro.com/category/skill-areas/relationships/
Anonymous
Sometimes you need to go from the most basic calculation to determine where the failure it. I would suggest building this in blocks. It is tempting to roll all of the logic into a single calculation but in situations where something breaks it is harder to find the issue. Plus, in measure, other than appearing in the field lists, you aren't really losing performance for having them available to build agains.
I would suggest first building a count and using it to create more defined logic.
CandidatesLast30 = CALCULATE(COUNT(Assignments[CandidateId]); PREVIOUSMONTH(Dates[Date].[Date]))
Candidates Added = COUNT(Assignments[CandidateID]) -- side note, in my data I would use DISTINCTCOUNT
Drop that calculation onto a table with the months as columns and see if it works.
Does it work? Do you get the result you should? If yes, build a calculation for the previous month. I personally use DATEADD instead of the wrappers like PREVIOUSMONTH as I am old school.
Candidates Added Last 30 = CALCULATE([Candidates Added], DATEADD(Dates[Date], -30, Days))
Drop that on your table as well. Does it give you the last months total in the current month?
Keep in mind that the filter for month needs to be set in the table or by the page for this to work. If you have just a card, you need to define current month in order for last month to attribute correctly.
If these measures work, you can build them into a single measure if you prefer using Var like this:
Candidates Added Last Month =
Var CandidatesAdded = COUNT(Assignments[CandidateID])
Return
CALCULATE([CandidatesAdded], DATEADD(Dates[Date], -30, Days))
- Anonymous7 years agoNot applicable
Hi kcantor and thanks for contributing!
When counting all the candidatesID, i get 2845, or 1532 when using distinctcount.
Candidates Added = COUNT(Assignments[CandidateID])
But when adding the dates, I get some issues. Days does not work for me, I get an error. I need to use day.
Candidates Added Last 30 = CALCULATE([Candidates Added]; DATEADD(Dates[Date]; -30; DAY))
Still, I get 2845 from that ones as well.
- kcantor7 years agoCommunity Champion
Anonymous
*When counting all the candidatesID, i get 2845, or 1532 when using distinctcount.
Which number is correct?My assumption would be that distinct would give you the correct number.
*Days does not work for me, I get an error. I need to use day.
Yes, sometimes when typing in this forum I use the plural because I get in a hurry. Sorry, my bad.
If you use distinct count and DAY and put the month on the columns, does the number for last 30 day give you the same number as the distinct count for the previous month? (Which makes me question if you want month over month shuold we use -1, MONTH in the calculation instead)
Can you share any data or a file?
Also, have you used this resource before? It may be a better method for you.
https://powerbi.tips/2016/07/measures-month-to-month-percent-change/
- Anonymous7 years agoNot applicable
1532 is correct. When I get the dates correct, I'm going to match it with the ID in another table.
I could share the file with you in a private message? And we can share the solution here if we find it :)