cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DXF_83
Helper III
Helper III

To calculate different taxes by year and product

Dear community,

I need to calculate a tax column, which varies by year, and it is applied to a product.

ProductYearPrice
A202020
B202121
A202122
A202223

 The tax should be applied just to product A, and if the year is <2022, it will be 7% of the price; otherwise will be 4% of the price.

I have tried a calculated column:

Tax= if(Table[Year]<2022,filter(Table,Table[Product]=A)*0.07,filter(Table,Table[Product]=21)*0.04). Unfortunately it didn't work well.
Any tips on this?
 
Thanks in advance.
 
Cheers
1 ACCEPTED SOLUTION
camargos88
Super User III
Super User III

@DXF_83 ,

 

You can create this new column using Power Query:

if [Product] = "A" then
   if [Year] < 2022 then [Price] * 0.07 else [Price] * 0.04
else null

 

Capture.PNG

 

Or this for a calculated column:

Tax_DAX = IF('Table'[Product] = "A", IF('Table'[Year] < 2022, 'Table'[Price] * 0.07, 'Table'[Price] * 0.04), BLANK())

 

Capture.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

1 REPLY 1
camargos88
Super User III
Super User III

@DXF_83 ,

 

You can create this new column using Power Query:

if [Product] = "A" then
   if [Year] < 2022 then [Price] * 0.07 else [Price] * 0.04
else null

 

Capture.PNG

 

Or this for a calculated column:

Tax_DAX = IF('Table'[Product] = "A", IF('Table'[Year] < 2022, 'Table'[Price] * 0.07, 'Table'[Price] * 0.04), BLANK())

 

Capture.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors