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
adilk
Helper I
Helper I

How to show percentage increase metric (week on week or month on month) depending on slicer?

Hi,

We have a weekly dashboard that can also double up as a monthly one.

I already have a 'Card' to show the metric for the current week. I would like Power BI to identify the date selection in the slicer and then show the % increase comparing current week to previous week and show % increase.

Also, if the selection is an entire month, then show the Card metric (% increase ) compared to previous month, not previous same number of days. How can I accomplish this?

Very new to Power BI . Thanks.

Thanks.

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

Hi @adilk,

 

Perhpas you can take a look at below formulas:

 

Add a table to store the calculate date range.

 

Table formula:

 

DateUnit = UNION(ROW("Unit","Day"),ROW("Unit","Week"),ROW("Unit","Month"),ROW("Unit","Year"))

 

Write the measures to calculate the specify data range.

 

Measures:

 

SelectUnit = IF(HASONEVALUE(DateUnit[Unit]),VALUES(DateUnit[Unit]),BLANK()) // get the select item from slicer

CurrentDate = MAX(Test[Date]) // current date from source table

Dayly Increase = 
var currAmount= SUMX(FILTER(ALL(Test),Test[Date]=[CurrentDate]),[Amount])
var previousAmount=SUMX(FILTER(ALL(Test),Test[Date]=[CurrentDate]-1),[Amount])
return
(previousAmount-currAmount)/previousAmount

Weekly Increase = 
var currAmount= SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])&&WEEKNUM(Test[Date])=WEEKNUM([CurrentDate])),[Amount])
var previousAmount=SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])&&WEEKNUM(Test[Date])=WEEKNUM([CurrentDate])-1),[Amount])
return
(previousAmount-currAmount)/previousAmount

Monthly Increase = 
var currAmount= SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])&&MONTH(Test[Date])=MONTH([CurrentDate])),[Amount])
var previousAmount=SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])&&MONTH(Test[Date])=MONTH([CurrentDate])-1),[Amount])
return
(previousAmount-currAmount)/previousAmount

Yearly Increase = 
var currAmount= SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])),[Amount])
var previousAmount=SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])-1),[Amount])
return
(previousAmount-currAmount)/previousAmount

DynamicIncrease = SWITCH([SelectUnit],"Day",[Dayly Increase],"Week",[Weekly Increase],"Month",[Monthly Increase],"Year",[Yearly Increase])

 

BTW, you should add some condition to deal with the year/month/week convert issue.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @adilk,

 

Perhpas you can take a look at below formulas:

 

Add a table to store the calculate date range.

 

Table formula:

 

DateUnit = UNION(ROW("Unit","Day"),ROW("Unit","Week"),ROW("Unit","Month"),ROW("Unit","Year"))

 

Write the measures to calculate the specify data range.

 

Measures:

 

SelectUnit = IF(HASONEVALUE(DateUnit[Unit]),VALUES(DateUnit[Unit]),BLANK()) // get the select item from slicer

CurrentDate = MAX(Test[Date]) // current date from source table

Dayly Increase = 
var currAmount= SUMX(FILTER(ALL(Test),Test[Date]=[CurrentDate]),[Amount])
var previousAmount=SUMX(FILTER(ALL(Test),Test[Date]=[CurrentDate]-1),[Amount])
return
(previousAmount-currAmount)/previousAmount

Weekly Increase = 
var currAmount= SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])&&WEEKNUM(Test[Date])=WEEKNUM([CurrentDate])),[Amount])
var previousAmount=SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])&&WEEKNUM(Test[Date])=WEEKNUM([CurrentDate])-1),[Amount])
return
(previousAmount-currAmount)/previousAmount

Monthly Increase = 
var currAmount= SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])&&MONTH(Test[Date])=MONTH([CurrentDate])),[Amount])
var previousAmount=SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])&&MONTH(Test[Date])=MONTH([CurrentDate])-1),[Amount])
return
(previousAmount-currAmount)/previousAmount

Yearly Increase = 
var currAmount= SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])),[Amount])
var previousAmount=SUMX(FILTER(ALL(Test),Test[Date].[Year]=YEAR([CurrentDate])-1),[Amount])
return
(previousAmount-currAmount)/previousAmount

DynamicIncrease = SWITCH([SelectUnit],"Day",[Dayly Increase],"Week",[Weekly Increase],"Month",[Monthly Increase],"Year",[Yearly Increase])

 

BTW, you should add some condition to deal with the year/month/week convert issue.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

If you can wait 12 hours, I have a blog post going live that will help you with this. 

Edit:  Here is the blog article http://exceleratorbi.com.au/dax-time-intelligence-beginners/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

cool, thx. will wait for the blog post.

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.

Top Solution Authors
Top Kudoed Authors