简体   繁体   English

PowerBI 矩阵的总和

[英]Total of PowerBI matrix

How to make Totals in powerBI matrix to be not SUMmed for each column?如何使 powerBI 矩阵中的总计不针对每一列求和?

I have a percentage measure which says which project made which ratio of revenue out of whole portfolio for each month, but the % are SUMmed for Total.我有一个百分比度量,它表示哪个项目每个月在整个投资组合中的收入比例,但百分比是总计的总和。

Example:例子:

全部的

Is there a way how to put average of % instead of SUM in Total?有没有办法将 % 的平均值而不是 SUM 放在 Total 中?

Measure I am using:我正在使用的措施:

Klient/Portfolio Ratio =
DIVIDE(
    'POHODA EXPORT'[SUMX(price)];
    'POHODA EXPORT'[MeasurePortfolio]
)

When MeasurePortfolio is:当 MeasurePortfolio 为:

MeasurePortfolio =
CALCULATE(
    SUMX(
        DISTINCT('POHODA EXPORT'[Concatenate]);
        FIRSTNONBLANK(
            'POHODA EXPORT'[Suma Portfolio];
            0
        )
    ) / DISTINCTCOUNT('POHODA EXPORT'[Concatenate])
)

and Suma Portfolio is a column calculated as: Suma Portfolio 是一个计算如下的列:

Suma Portfolio = 
var PM1 ='POHODA EXPORT'[PMs.PM]
var month1 = MONTH('POHODA EXPORT'[1.MM.YYYY])
var year1 = YEAR('POHODA EXPORT'[1.MM.YYYY])
return
CALCULATE(
    SUM('POHODA EXPORT'[Suma bez DPH]);
    FILTER(
        'POHODA EXPORT';
        'POHODA EXPORT'[PMs.PM] = PM1
            && MONTH('POHODA EXPORT'[1.MM.YYYY]) = month1
            && YEAR('POHODA EXPORT'[1.MM.YYYY]) = year1
    )
)

Concatenate is a column which makes a unique reference from Month, Year and Project Manager to able to proceed with requirements. Concatenate 是一个列,它可以从 Month、Year 和 Project Manager 中获得唯一的参考,以便能够继续处理需求。

What I am trying to achieve is out of data certain PM has assigned portfolio of projects, and get them a ratio percentage for project/portfolio.我想要实现的是某些 PM 已分配项目组合的数据,并为他们获得项目/组合的比率百分比。

Mentioned formulas works succesfully, but then Subtotal has a wrong value, when Subtotal SUMS percentage for each month instead of averaging them, so for one project it make the percentage 400% Subtotal.提到的公式可以成功运行,但是小计的值错误,当每个月的小计总和百分比而不是平均它们时,因此对于一个项目,它使百分比为 400% 小计。

I don`t understand the logic how Subtotal is calculated, I calculate project Margin in percentage, but % for each month is not SUMmed in Total.我不明白如何计算小计的逻辑,我以百分比计算项目保证金,但每个月的百分比不是总计。 And also there are calculations using measures and columns.还有使用度量和列的计算。 I tried to google but not succesfully.我试图谷歌但没有成功。

Thanks谢谢

To get要得到

average of % instead of SUM in Total平均百分比而不是总和

you should calculate the average, not the division.你应该计算平均值,而不是除法。
In your realization Total value actually divides annual 'POHODA EXPORT'[SUMX(price)] by annual 'POHODA EXPORT'[MeasurePortfolio] .在您的实现中,价值实际上将年度 'POHODA EXPORT'[SUMX(price)]除以年度 'POHODA EXPORT'[MeasurePortfolio]

Try to put your measure inside an AVERAGE() function like:尝试将您的度量放在AVERAGE()函数中,例如:

Average Measure = 
AVERAGE([Your Measure])

The hint is that the average of monthly value is monthly value!提示是月值的平均值就是月值! So replacing your measure with this measure will have no affect to monthly values in matrix, but the total will be calculated correctly.因此,用此度量替换您的度量不会影响矩阵中的月度值,但会正确计算总数。
Using additional function will slow down your report so use this advice wisely.使用附加功能会减慢您的报告速度,因此请明智地使用此建议。

I'm not sure I follow your description, but I expect your issue is using a SUM in the expression inside a SUMX function.我不确定我是否遵循您的描述,但我希望您的问题是在 SUMX 函数内的表达式中使用 SUM。 Within any ...X function, the expression to be calculated for each row should always be a naked column reference or a measure, to avoid weird results like these.在任何 ...X 函数中,要为每一行计算的表达式应始终是裸列引用或度量,以避免出现此类奇怪的结果。 Your can create a measure to just to the SUM, and reference that and it starts working as you would expect.您可以创建一个仅针对 SUM 的度量,并引用它,它就会开始按您的预期工作。

I don't know why, it just is.我不知道为什么,就是这样。 There are many gotchas like this in DAX, where the default behaviour is counterintuitive.在 DAX 中有很多这样的陷阱,默认行为是违反直觉的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM