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 custom calendar table linked to my data, which allows me to aggregate my data into period of custom Weeks, or Months, Custom Financial quarters etc. I then have sales and performance data which I've related to the custom calendar.
I'm building a dashboad to show period performance at whichever level I select. So my charts are showing period on period tracking for each of the measures.
Now I want to use a Card Visual to show the previous periods total, so that every time my data refreshes and we've moved into a new period, it automatically filters itself to showing the previous period, for example, let's say previous week. How can I do this? At the moment I have to open up the dashboard every week/month and manually update all the Visual level filters across a number of cards.
And on my charts, I want to exclude the current (incomplete) period until we move out of it and it becomes complete, but I don't want to have to manually change the filters every time across a number of charts. Again, how can I do this?
I am hoping that makes sense and that someone can help! I'm surmising that it should be easy to put a current/previous week/month/quarter type flag into my custom table, which will refresh every time my data refreshes but I'm not sure what to use or how to then make it update the flag dynamically or if there's a better solution?
Solved! Go to Solution.
Hi @Anonymous,
I just forgot that important part. Try the formula below.
Previous Week Sales = VAR currentWeek = MAX ( 'CalendarTable'[WeekNumber] ) VAR currentYear = MAX ( 'CalendarTable'[Year] ) RETURN IF ( currentWeek = 1, CALCULATE ( [Total Sales], FILTER ( ALL ( CalendarTable ), 'CalendarTable'[Year] = currentYear - 1 && 'CalendarTable'[WeekNumber] = 52 ) ), CALCULATE ( [Total Sales], FILTER ( ALL ( CalendarTable ), 'CalendarTable'[Year] = currentYear && 'CalendarTable'[WeekNumber] = currentWeek - 1 ) ) )
Regards
Hi @Anonymous,
I assume that you already have the Year and WeekNumber columns in your Calendar table. If not, you can use the formula below to add them first.
Year = YEAR ( 'CalendarTable'[Date] ) WeekNumber = WEEKNUM ( 'CalendarTable'[Date] )
Then, you should be able to use the formula below to create a measure to calculate the previous week sales, then show it on a Card visual. And you can use similar formulas to calculate sales for other previous periods.
Previous Week Sales = VAR currentWeek = MAX ( 'CalendarTable'[WeekNumber] ) VAR currentYear = MAX ( 'CalendarTable'[Year] ) RETURN CALCULATE ( [Total Sales], FILTER ( ALL ( CalendarTable ), 'CalendarTable'[Year] = currentYear && 'CalendarTable'[WeekNumber] = currentWeek - 1 ) )
Regards
This is great, thanks. Just one question, how would i build in an if statement to say if the curent week is week 1, use previous year, week 52?
Hi @Anonymous,
I just forgot that important part. Try the formula below.
Previous Week Sales = VAR currentWeek = MAX ( 'CalendarTable'[WeekNumber] ) VAR currentYear = MAX ( 'CalendarTable'[Year] ) RETURN IF ( currentWeek = 1, CALCULATE ( [Total Sales], FILTER ( ALL ( CalendarTable ), 'CalendarTable'[Year] = currentYear - 1 && 'CalendarTable'[WeekNumber] = 52 ) ), CALCULATE ( [Total Sales], FILTER ( ALL ( CalendarTable ), 'CalendarTable'[Year] = currentYear && 'CalendarTable'[WeekNumber] = currentWeek - 1 ) ) )
Regards
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 |
---|---|
97 | |
94 | |
74 | |
71 | |
64 |
User | Count |
---|---|
143 | |
109 | |
103 | |
82 | |
74 |