Power BI – 根据计算结果一次性创建多个度量值

huangapple go评论69阅读模式
英文:

Power BI - Create multiple measures at once based on the result of a calculation

问题

我是新手使用 Power BI,恳请协助。

我有一个职位表,其中有一个类型列(现场、远程或混合)和一个按州分的空缺位置列。

我知道 CALCULATE 方法的工作原理,也知道如何分别创建度量来执行此操作,类似于以下内容:

hybrid_job_california_state = CALCULATE(
COUNTROWS(job), job[type]="hybrid"
)

不过,我想象中应该有一种更简单的方法来做这个,我不想一遍又一遍地复制相同的代码来获取每个州的总数。

我了解了 GROUPBY,但不知道如何在这种情况下应用它。

有没有办法让我按州获取职位总数,而不必手动为每个州创建度量?

英文:

I'm new to Power BI and kindly request assistance

I have a job table that has a type column (on-site, remote or hybrid) and a vacancy location column by State

I know how the CALCULATE method works and I know how to individually create measures to do this, something similar to this

 hybrid_job_california_state = CALCULATE(
   COUNTROWS(job), job[type]="hybrid"
 )

However, I imagine there is a simpler way to do this, I wouldn't want to replicate the same code over and over again to get the total for each State

I read about GROUPBY, but I couldn't understand how to apply it to this situation

Is there any way for me to have the sum of jobs by state without having to manually create a measure for each state?

答案1

得分: 2

抱歉,我只会翻译文本内容,不回答问题。以下是您提供的文本的翻译:

"Sorry if I misunderstand:
在最简单的方式中,视觉将为您执行过滤和聚合。

例如,如果您在一列中创建一个表视觉,该列包含‘job’[type],并且在第二列中包含‘job’的任何列,并进行COUNT聚合,它将根据工作类型进行计数。

否则,您可能需要查看ALLEXCEPT (),以明确地应用/设置度量中的过滤器。

祝你好运!

编辑:两者都适用于多个条件,即如果您在表视觉中的另一列中添加了州,则它也将包含在过滤中。"

英文:

Sorry if I misunderstand:

In the simplest way, the visual will do the filtering and aggregation for you.

e.g., if you create a table visual with ‘job’[type] in one column and in the second column any column from ‘job’ aggregated by COUNT it will count with respect to the job type.

Otherwise, you may want to have a look on the
ALLEXCEPT () to apply/set the filter in your measure explicitly.

Good luck!

Edit: both work with multiple criteria, i.e. if you add the state in another column in the table visual, it’s included to the filtering as well

huangapple
  • 本文由 发表于 2023年5月14日 05:40:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76244997.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定