Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
nkurian
Frequent Visitor

Value of Measure against previous period

Hi,

 

*I am a newbie, so it is very much possible that this is a silly/easy question*

 

I have a table that shows gives me students enrolments into courses . There is a enrolment date as well.

I have added a measure Number of Enrolments = countA('Student Enrolments'[UserName]).

If I add a slicer with Enrolment Date, I can pick the year for which I need the enrolment count. I am stuck on the following requirement.

If I pick a year to get the count of enrolments for the year I need to get the growth % with respect to last year. 

Example, if I pick year 2016 in the time slicer, I should get the following.

 

 

Year-Selected Previous-Yr Growth %

120              100                   20

 

Thanks,

Ninu

 

 

 

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @nkurian,

 

In your scenario, you can create a new table group on [Enrolment Date] column and return the number of the [UserName] for each year. Then you can add calculated columns to return growth value. See:

 

Table = SUMMARIZE(Table1,Table1[Enrolment Date],"count",COUNTA(Table1[UserName]))

 

CountPrevious = calculate(SUM('Table'[Count]),filter('Table','Table'[Enrolment Date]=EARLIER('Table'[Enrolment Date])-1))

 

Growth = if('Table'[CountPrevious]=0, BLANK(), DIVIDE('Table'[Count]-'Table'[CountPrevious],'Table'[CountPrevious]))

 

a1.PNG

a2.PNG

a3.PNG

 

If I misunderstand your requirement, please share some sample data and expected results for our analysis.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-qiuyu-msft
Community Support
Community Support

Hi @nkurian,

 

In your scenario, you can create a new table group on [Enrolment Date] column and return the number of the [UserName] for each year. Then you can add calculated columns to return growth value. See:

 

Table = SUMMARIZE(Table1,Table1[Enrolment Date],"count",COUNTA(Table1[UserName]))

 

CountPrevious = calculate(SUM('Table'[Count]),filter('Table','Table'[Enrolment Date]=EARLIER('Table'[Enrolment Date])-1))

 

Growth = if('Table'[CountPrevious]=0, BLANK(), DIVIDE('Table'[Count]-'Table'[CountPrevious],'Table'[CountPrevious]))

 

a1.PNG

a2.PNG

a3.PNG

 

If I misunderstand your requirement, please share some sample data and expected results for our analysis.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-qiuyu-msft

 

Thanks for the suggestion. The enrolment Date is a date. So, I extracted the Enrolment Year into a custom column in the base table and your suggestion worked beautifully! Thanks much!

 

-Ninu

ankitpatira
Community Champion
Community Champion

@nkurian Assuming you have data in format of,

 

Student,EnrolDate

1,01/01/2015

2,01/01/2016

 

you can first add Index column in power bi desktop query editor by going to edit queries and under Add Column tab click Add Index Column.

 

Then created calculated column PreviousYearEnrol as 

 

PreviousYearEnrol =
IF(
'YOURTABLE'[IndexColumn] = 0,
'YOURTABLE'[student],
LOOKUPVALUE(
'YOURTABLE'[student],
'YOURTABLE'[IndexColumn],
'YOURTABLE'[IndexColumn]-1)
)

 

Then another calculated column PercentageDifference as

 

PercentageDiffernece = YOURTABLE[student] / sam[PreviousYearEnrol].

@ankitpatira,

 

Unfortunately, the suggestion provided does not meet the requirement. The requirement is  to get count the number of records( enrolments in this case) for the selected year and also provide the count of records on the previous year.

 

I have a measure that counts the records and if I put that measure in the table visual with year field, it gives me the count grouped by year. But my requirement is that when I select a particular year, say via a slicer visual, it should show me the count of enrolments from that year AND from previous year and the growth percentage.

 

Thanks,

Ninu

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.