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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
craig811
Helper III
Helper III

Formula to work out sales varaince by period

Hi all,

 

I am trying to work out the sales variance by period, however I get an error as my period in in Text format:

 

Formula:

Net Sales Variance % = DIVIDE([Net Sales GBP],[Net Sales By Period],0)-1
 
My Period looks like: Jun-21(In text format)
Start date of period :01/01/2021 (Date format)
End date of period :31/01/2021 (Date format)
 
Any ideas how I get the above formula to work for my Periods? Do I need to use the 'Start' and 'End' date instead?
 
Many thanks
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

PBI is not Excel. DAX is not the formula language which you use in Excel. It's more powerful but more complex. To be able to program in it you have to learn quite a bit of theory. Yes, THEORY. Without this you'll never understand DAX.

 

Your problem stems from the fact that you are not familiar with (dimensional) data modeling in PBI. It does not matter that your Period Name is text. You should have another column that is of proper data type (DATE) in your Calendar table (there must be a proper calendar in your model) and you must use this column for all time-intel calculations. 

 

daxer_0-1625046745692.png

What you want to do is achieved through 1) the selection of your Period Name from the calendar and 2) DAX that calculates based on the Date column in the calendar. Nothing else is needed.

daxer_1-1625046899688.png

The rest is on the page I gave you a link to.

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

For this very task please read this: Standard time-related calculations – DAX Patterns

On the right-hand side (where the TOC is) look for "Month-over-month growth".

Thank you Daxer , however the Power BI formula still do not pick up the Period. I can do this very easily in Excel.

Period NameNet Sales GBPPercentage 
Apr-2180000060
Jun-21500000-16.6667
May-21600000 

 

I just use the forumla Growth = (Current Period - Prior Period)/Prior Period * 100).  The problem I am having is the Power BI won't recongise the Period Name as it is in text format. 

 

This should be a simple formula in Power BI, what am I missing here? Thank you again.

Anonymous
Not applicable

PBI is not Excel. DAX is not the formula language which you use in Excel. It's more powerful but more complex. To be able to program in it you have to learn quite a bit of theory. Yes, THEORY. Without this you'll never understand DAX.

 

Your problem stems from the fact that you are not familiar with (dimensional) data modeling in PBI. It does not matter that your Period Name is text. You should have another column that is of proper data type (DATE) in your Calendar table (there must be a proper calendar in your model) and you must use this column for all time-intel calculations. 

 

daxer_0-1625046745692.png

What you want to do is achieved through 1) the selection of your Period Name from the calendar and 2) DAX that calculates based on the Date column in the calendar. Nothing else is needed.

daxer_1-1625046899688.png

The rest is on the page I gave you a link to.

 

Thank you , I have now created the correct DAX formula. Job done 🙂

Anonymous
Not applicable

With this amount of info it's not possible to say anything.

Here's how to get your questions answered (quickly).

Thanks for the reply,

 

Ok I have three periods of sales data:

Apr-21

May-21

Jun-21

 

I would like to work the increase or decrease of Sales by period. So for example sales from May-21 may have increased by 7% compared to Apr-21 . I am trying to work out the best formula to use for this task.  Does that make sense?

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors