DAX Formula To Determine Discount Based On Date (Q1,Q2,Q3,Q4)

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all..
how to determine discount for 3 items Car, Trucks, Bus
this rule:
- my date in dd-mm-yyyy (format date)
- my target in col "car", trucks, bus with different discount
- the discount same rate for all regions
for Car:
- in Quarter 1 (<=1/03/2022) -- get discount 5%
- in Quarter 2 (1/4/2022 till 1/6/2022), --- get discount 7%
- in Quarter 3 (1/7/2022 till 1/9/2022), --- get discount 8%
- in Quarter 4 (1/10/2022 till 1/12/2022), --- get discount 10%
for Trucks:
- in Quarter 1 (<=1/03/2022) -- get discount 10%
- in Quarter 2 (1/4/2022 till 1/6/2022), --- get discount 12%
- in Quarter 3 (1/7/2022 till 1/9/2022), --- get discount 20%
- in Quarter 4 (1/10/2022 till 1/12/2022), --- get discount 25%
-etc..
raw data formula power bi.xlsx
ABCDEFGHI
1original/raw datadesired result/after formula
2RegionDate (dd-mm-yyyy)CarTrucksBusCarTrucksBus
3Region A01/03/20220005%10%20%
4Region A01/04/20220007%12%25%
5Region A01/05/20220007%12%25%
6Region A01/06/20220007%12%25%
7Region A01/07/20220008%20%30%
8Region A01/08/20220008%20%30%
9Region A01/09/20220008%20%30%
10Region A01/10/202200010%25%35%
11Region A01/11/202200010%25%35%
12Region A01/12/202200010%25%35%
13Region B01/03/20220005%10%20%
14Region B01/04/20220007%12%25%
15Region B01/05/20220007%12%25%
16Region B01/06/20220007%12%25%
17Region B01/07/20220008%20%30%
18Region B01/08/20220008%20%30%
19Region B01/09/20220008%20%30%
20Region B01/10/202200010%25%35%
21Region B01/11/202200010%25%35%
22Region B01/12/202200010%25%35%
23Region C01/03/20220005%10%20%
24Region C01/04/20220007%12%25%
25Region C01/05/20220007%12%25%
26Region C01/06/20220007%12%25%
27Region C01/07/20220008%20%30%
28Region C01/08/20220008%20%30%
29Region C01/09/20220008%20%30%
30Region C01/10/202200010%25%35%
31Region C01/11/202200010%25%35%
32Region C01/12/202200010%25%35%
Sheet1

how to figure out this problem?

susant
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Mcode Use this same concept for Busses

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date (dd-mm-yyyy)", type date}}),
    #"Inserted Quarter" = Table.AddColumn(#"Changed Type", "Quarter", each Date.QuarterOfYear([#"Date (dd-mm-yyyy)"]), Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Inserted Quarter", "Car", each if[Quarter]=1 then .05 else if [Quarter]= 2 then .07 else if [Quarter]= 3 then .08 else .1),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Truck", each if[Quarter]=1 then .1 else if [Quarter]= 2 then .12else if [Quarter]= 3 then .20 else .25),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"Car", Percentage.Type}, {"Truck", Percentage.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Quarter"})
in
    #"Removed Columns"
 
Upvote 0
Solution

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top