powerbi - DAX 公式计算奖金或所得税
问题描述
我正在尝试制定一项计算例如所得税的措施。起点始终是赚到的钱,我们称起点为 NetProfit。例如,我们以 10 万美元的净利润为例
Taxrate first 60k NetProfit is 40%
Taxrate remaining NetProfit is 70%
The outcome of the measure is amount of Tax
60k x 0.4 = 24k
40k x 0.7 = 28k
Total Tax = 52k (24k + 28k)
解决方案
如果您有如下事实表
| Profit |
|--------|
| 40000 |
| 60000 |
| 100000 |
| 10000 |
| 61000 |
您可以通过以下措施实现总税
total:= SUM('fact'[Profit])
// if you want the subtotal tax with 60:40
totalTax:=
VAR _1stTaxSlot = 60000
VAR _totalTax =
IF (
[total] <= _1stTaxSlot,
[total] * 0.6,
( [total] - _1stTaxSlot ) * 0.4 + _1stTaxSlot * 0.6
)
RETURN
_totalTax
//if you want the subtotal level with summation of all calculated tax
totalTax2 :=
VAR _1stTaxSlot = 60000
VAR _totalTax2 =
SUMX (
'fact',
IF (
'fact'[Profit] <= _1stTaxSlot,
'fact'[Profit] * 0.6,
( ( 'fact'[Profit] - _1stTaxSlot ) * 0.4 ) + ( _1stTaxSlot * 0.6 )
)
)
RETURN
_totalTax2
推荐阅读
- java - Maven项目Jenkins编译报错:错误:包org.apache.commons不存在
- sql-server - 找不到列“dbo”或用户定义的函数或聚合“TryConvertInt”,或者名称不明确
- python - 使用 itemgetter 或比 lambda 更快的方法按元组第 n 个元素对嵌套元组列表进行排序
- postman - 一个变量的当前值可以用作 Postman 中另一个变量的 Key 吗?
- raspberry-pi - 我们如何通过键盘在树莓派中选择 wifi
- java - 错误的屏幕宽度返回 javaFX
- nativescript - Nativescript 音视频通道
- javascript - 填充对象中的字段,来自其他对象
- node.js - Google API 重命名导入的变量会产生错误
- android - 在 ionic cordova 中构建到 android 时出现错误