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
Anonymous
Not applicable

Calculate dynamic percentage change quarter on quarter and year on year

Hello,

 

I am new to Power Bi. I am trying to calculate the percentage change in the number of customers quarter on quarter as well as year on year  based filter applied on two columns- Energy and Supplier. I tried below code but I guess I am going wrong with the Date logic. 

 

change perc = VAR ValueLastYear =
CALCULATE (
SUM ( ElectricityGasCustomerNum[CustomerNumber] ),
FILTER (
ElectricityGasCustomerNum,
ElectricityGasCustomerNum[Date]
= ( EARLIER ( ElectricityGasCustomerNum[Date] ) - 1 )
&& ElectricityGasCustomerNum[Energy] = EARLIER ( ElectricityGasCustomerNum[Energy] )
&& ElectricityGasCustomerNum[Supplier] = EARLIER ( ElectricityGasCustomerNum[Supplier] )
)
)
RETURN
IF (
ISBLANK ( ValueLastYear ),
0,
( ElectricityGasCustomerNum[CustomerNumber] - ValueLastYear )
/ ValueLastYear
)

 

 

DateEnergySupplierCustomerNumber%Change
01/01/2009ElectricityA40000 
01/04/2009ElectricityA190000 
01/07/2009ElectricityA260000 
01/10/2009ElectricityA320000 
01/01/2010ElectricityA370000 
01/04/2010ElectricityA410000 
01/07/2010ElectricityA400000 
01/10/2010ElectricityA450000 
01/01/2009ElectricityB25000 
01/04/2009ElectricityB140000 
01/07/2009ElectricityB100000 
01/10/2009ElectricityB200000 
01/01/2010ElectricityB310000 
01/04/2010ElectricityB280000 
01/07/2010ElectricityB350000 
01/10/2010ElectricityB390000 
01/01/2009GasA30000 
01/04/2009GasA90000 
01/07/2009GasA60000 
01/10/2009GasA30000 
01/01/2010GasA290000 
01/04/2010GasA320000 
01/07/2010GasA390000 
01/10/2010GasA370000 

 

Any help would be greatly appreciated.

 

Thanks!

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Check this file:  Download PBIX 

The key point is to have a date calendar, so you can use the data intel functions.

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Check this file:  Download PBIX 

The key point is to have a date calendar, so you can use the data intel functions.

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Anonymous
Not applicable

Hi @camargos88 ,

 

Thank you for your solution. It worked. I am building a dashboard for this type of data. It would be great if you could suggest what all insights I can show may be as a summary using the charts of power bi.

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