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

Redistribute sales across the year based on quarter

Hi Everyone, Good day!

I am stuck with a situation where I need to write DAX to redistribute sales values based on the date range in quarter. I will try to explain it as easily as possible.

Please see the below table ( lets call it 'Info') with sample data. Here the month is in YYYYMM format so basically 202101 means Jan 2021 and corresponding values in "sales" column is the data for that month.

Karma777_0-1669704746192.png
Here for simplicity the total sales is 1000 for the whole year. Now based on quarter, the sales value need to be resdributed. The formula is :
For Q1, 10% of Total Sales
For Q2, 20% of Total Sales

For Q3, 30% of Total Sales

For Q4, 40% of Total Sales
Example : Here Total Sales = 1000. So Q1 sales = 10% of 1000 = 100. Now there are there months in Q1 - Jan, Feb, March. This value for Q1 would be equally distributed for each month i.e., 33.33 each for Jan, feb, March.
Based on this logic, I need to create a new calculated column ( lets call it 'Sales New') which should have values like shown below.

Karma777_1-1669705560537.png

Can somebody please help in writing DAX for this calculated column. Thanks in advance!

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Karma777 

Please try this column,

Sales New = 
var _total= 1000
var _q1=0.1
var _q2=0.2
var _q3=0.3
var _q4=0.4
var _q= VALUE(RIGHT('Table'[Month],2))
return SWITCH(TRUE(),
_q>=1 && _q<4,_total*_q1/3,
_q<7,_total*_q2/3,
_q<10,_total*_q3/3,
_q<13,_total*_q4/3
)

vxiaotang_0-1669802660002.png

 

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xiaotang
Community Support
Community Support

Hi @Karma777 

Please try this column,

Sales New = 
var _total= 1000
var _q1=0.1
var _q2=0.2
var _q3=0.3
var _q4=0.4
var _q= VALUE(RIGHT('Table'[Month],2))
return SWITCH(TRUE(),
_q>=1 && _q<4,_total*_q1/3,
_q<7,_total*_q2/3,
_q<10,_total*_q3/3,
_q<13,_total*_q4/3
)

vxiaotang_0-1669802660002.png

 

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

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.