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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors