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
JoeNewton
Frequent Visitor

% comp works for 1 week, but breaks with 4 week view?

Hi, 

 

I have successfully added a % comp to my one week view that looks like this for headers:

 

Retailer | 2022 sales | 2021 sales | % comp |

 

But in my 4 week tab, which has the following relative dates, it doesn't work:

 

Date added to filter, relative date, is in the last 4 weeks. 

 

The problem is that the amounts are correct, but it should be a negative number but it is positive. I have no idea why or how to fix. For example, it says 6% when it should be -6%. 

 

Hopefully this all makes sense, thanks!

1 ACCEPTED SOLUTION

OK so I found the issue. It was calculating correctly, but power bi was not showing the negative. I have no idea why not, but when I hovered my mouse over it I was able to see that it was in fact negative. I changed the format to red to show this. 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@JoeNewton ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Usually formula is divide( [current] -[prior],[prior])

 

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8

OK so I found the issue. It was calculating correctly, but power bi was not showing the negative. I have no idea why not, but when I hovered my mouse over it I was able to see that it was in fact negative. I changed the format to red to show this. 

So when I use your solution the % values get very wrong for some reason.

 

YOY Growth % = DIVIDE('Top Customers Data'[POS $]-'Top Customers Data'[POS $ LY], 'Top Customers Data'[POS $ LY])
 
This gets:
 
Retailer: X
POS $: 608k
POS $ LY: 644k
YOY Growth %: 598%
 
Before i had:

POS $ LY % difference from POS $ =
VAR __BASELINE_VALUE = SUM('Top Customers Data'[POS $])
VAR __VALUE_TO_COMPARE = SUM('Top Customers Data'[POS $ LY])
RETURN
    DIVIDE(__VALUE_TO_COMPARE - __BASELINE_VALUE, __BASELINE_VALUE)
 
Which got the correct % but negative
@amitchandak Added an @ to you in case you lost the thread 🙂

 

 

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.