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
JAnderson
New Member

divide values in column rows

I have Sold To Customer in the blacked out row and sales dollars based on years/months in the slicers.   It all comes from the same database.   I've read every post out there and can not figure out how to add a % difference column between 2016/2017 and 2017/2018.     Data is not a static database, it updates from a server 4X per day to populate the numbers.   How do I write this in DAX to add % increase or decrease based on each row in the columns? 

 

2018-05-23_13-51-01.jpg

1 ACCEPTED SOLUTION
lisaeugene
Frequent Visitor

I'm doing almost the same exact calculation for certain costs, too. I use the exact same slicer you're using. Here's how I've done it. 

 

  1. Create a measure to calculate this year's sales. TOTALSALES = SUM( YourTable[YourSales_Amt])
  2. Create 2nd measure to calculate sales for prev yr: TOTALSALES LY = CALCULATE([TOTALSALES],SAMEPERIODLASTYEAR('Date'[Date]))
  3. Create 3rd measure to calculate difference between last year and this year: DIFF BTW TY AND LY = IF( ISBLANK( [TOTALSALES LY]), BLANK(), [TOTALSALES] - [TOTALSALES LY])
  4. Create 4th measure to calc percent diff between the two years. PCT DIFF BTW TY and LY = [Diff btw TY and LY] / [TOTALSALES LY]

I'm sure there is a more elegant way to do this with DAX, but I'm still learning Power BI, so my formulas and procedures are more basic. Hope this helps. 

 

Hope this helps!

View solution in original post

1 REPLY 1
lisaeugene
Frequent Visitor

I'm doing almost the same exact calculation for certain costs, too. I use the exact same slicer you're using. Here's how I've done it. 

 

  1. Create a measure to calculate this year's sales. TOTALSALES = SUM( YourTable[YourSales_Amt])
  2. Create 2nd measure to calculate sales for prev yr: TOTALSALES LY = CALCULATE([TOTALSALES],SAMEPERIODLASTYEAR('Date'[Date]))
  3. Create 3rd measure to calculate difference between last year and this year: DIFF BTW TY AND LY = IF( ISBLANK( [TOTALSALES LY]), BLANK(), [TOTALSALES] - [TOTALSALES LY])
  4. Create 4th measure to calc percent diff between the two years. PCT DIFF BTW TY and LY = [Diff btw TY and LY] / [TOTALSALES LY]

I'm sure there is a more elegant way to do this with DAX, but I'm still learning Power BI, so my formulas and procedures are more basic. Hope this helps. 

 

Hope this helps!

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.