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 a table1 containing customerid, month, presenceboolean. I have a calendartable containing date,month,year.
Now I want to visualize a table with columns year, distinctcount customerid and distinctcount customerid previous year
I created two measures:
for current year : this_year= calculate(distinctcount(table1[customerid),filter(presenceboolean = 1))
for previous year :
previous_year = calculate(distinctcount(table1[customerid),sameperiodlastyear('calendartable'[date],filter(presenceboolean = 1))
the month field in table1 is formatted dd-mm-yyyy and is linked to the datefield in the calendertable
the dax formula for previous year does not give any result. I used the function previousyear to, but that did not give results either
What is wrong with my formula. Google did not help 🙂
@noobtopowerbi again pointing out this playlist which has all the time intelligence functions talked in detail along with how to compare with the previous year:
Mark date dimension as a date table - why and how?
Time Intelligence Playlist
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@noobtopowerbi I would be very careful using this approach because it is not the best practice and will hit the performance issues on the larger data table. If you want to do the things right way, following best practices, add the date table and use that for all-time intelligence-related measures. The choice is yours. Do it right, or have a short-term solution.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you for your answer. I tried the same using a calendar table containing year,month and year_month. Lin ked by year_month, but that did not help to.
I will dive into the suggestions on date topics. Sometime I will solve this 🙂
Just remember, it would be best practice to have your date table only contain unique values.
I must be doing something wrong, I get the right results for previous year but not for the actual year.
As I cannot add a pbix file to my posts I will give as much informations as possible :
This is the measure for current year :
Hi there, you may have a parentheses misplaced 🙂
Try:
presence this year = calculate(DISTINCTCOUNT('Table'[employee]),
Filter(all('Table'),'Table'[month]= 9,
'Table'[presence]=1)
)
Hello,
Based off your description, try the following:
Previous Year =
VAR Previous_Y = Year(MAX(DateTable[Date]))-1
Return
CALCULATE(COUNT(Table1[CustomerID]),FILTER(ALL(DateTable),Year(DateTable[Date])=Previous_Y))
@noobtopowerbi the month column in the table1, does it contain date value or month value? Can you share sample data? In the meantime, check out these related videos on my channel which have in-depth explanation of all time intelligence functions:
Importance of Date Dimension
Mark date dimension as a date table - why and how?
Time Intelligence Playlist
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
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 |
---|---|
109 | |
100 | |
83 | |
76 | |
65 |
User | Count |
---|---|
120 | |
108 | |
98 | |
83 | |
77 |