Forum Discussion
Previous Years data
Hi,
I have the data of students with columns "Applications Sent Date" (ASD) and "Course Start Date" (CSD).
Now for my visualisation, I would like to see a comparison side by side for the selected period for both the date ranges using individual slicers and the same data for the previous year.
Something like this:
Thanks
First step is to add a calendar to your data model. It will link to the application date and also to the course start date.
Then add a date slicer from the calendar table.
Next define your measures.
Applications = COUNTROWS(Courses) Started = CALCULATE(COUNTROWS(Courses),USERELATIONSHIP(Courses[Course Start Date],Dates[Date])) Applications prior period = var mind = min(Dates[Date]) var maxd = max(Dates[Date]) return calculate(countrows(Courses),datesbetween(Dates[Date],edate(mind,-12),edate(maxd,-12))) Started prior period = var mind = min(Dates[Date]) var maxd = max(Dates[Date]) return calculate(countrows(Courses),datesbetween(Dates[Date],edate(mind,-12),edate(maxd,-12)),USERELATIONSHIP(Courses[Course Start Date],Dates[Date]))This will give you maximum flexibility with the definition of your date range.
see attached
6 Replies
- lbendlinSuper User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523- glee1207Regular Visitor
Hi lbendlin ,
Thank you getting back to me.
I have attached a dummy data for your reference as I cannot share the actual data, but this should give you a fair idea of what I need.
Alongwith the data, there are 2 pivots showing what is needed.
I want a DAX formula, in which if I out a date filter for 2023 in the visual, it can take the data for the same range for 2022 and accordingly calculate the data.
Thanks and Regards
glee
- lbendlinSuper User
First step is to add a calendar to your data model. It will link to the application date and also to the course start date.
Then add a date slicer from the calendar table.
Next define your measures.
Applications = COUNTROWS(Courses) Started = CALCULATE(COUNTROWS(Courses),USERELATIONSHIP(Courses[Course Start Date],Dates[Date])) Applications prior period = var mind = min(Dates[Date]) var maxd = max(Dates[Date]) return calculate(countrows(Courses),datesbetween(Dates[Date],edate(mind,-12),edate(maxd,-12))) Started prior period = var mind = min(Dates[Date]) var maxd = max(Dates[Date]) return calculate(countrows(Courses),datesbetween(Dates[Date],edate(mind,-12),edate(maxd,-12)),USERELATIONSHIP(Courses[Course Start Date],Dates[Date]))This will give you maximum flexibility with the definition of your date range.
see attached