在 Excel 中,如果我位于一个名为“销售”且有四列的表中,我可以
销售量
Month, CustomerId, ProductId, TotalQuantity
Jan,1, CAR,
Feb,1, CAR,
Run Code Online (Sandbox Code Playgroud)
我可以添加一个公式:
=SUMIFS(Sales[Quantity],Sales[CustomerId],[@[CustomerId]])
Run Code Online (Sandbox Code Playgroud)
这将转到 Sales 表,并对按已输入公式的当前行的 CustomerID 筛选出的 CustomerID 列求和。
我尝试在 PowerBI 计算行中复制此内容,但无法让 @ 用于行引用。它就像
TotalQuantity = CALCULATE(SUM(Sales[Quantity]),Sales[CustomerId] = Sales[CustomerId]))
Run Code Online (Sandbox Code Playgroud)
知道如何获得同等的@工作吗?
我是 Rails 和 Heroku 的新手,并且创建了一个基本的应用程序。过去几周我一直在 Heroku 中仅使用 1 个 dyno。现在我已经增加到两个并且收到 CSRF 错误,因为一旦涉及第二个测功机,真实性令牌就会被重置。至少我是这么认为的。但我仍在学习。
\n\n我在播客等中听到过很多关于 Resque、Sidekiq、memcached 和 dalli 的内容。这是我需要去学习的东西,这样我就可以弄清楚如何保持这个用户会话为什么有多个测功机。
\n\n这是早期问题的后续问题,但我不确定它们是否相关。我也在和 phusion 乘客一起跑步。
\n\n2014-05-17T08:46:59.603754+00:00 app[web.2]: App 120 stdout: Started POST "/users/sign_in" for 58.7.233.232 at 2014-05-17 08:46:59 +0000\n2014-05-17T08:46:59.603819+00:00 app[web.2]: App 120 stdout: Processing by Devise::SessionsController#create as HTML\n2014-05-17T08:46:59.603854+00:00 app[web.2]: App 120 stdout: Parameters: {"utf8"=>"\xe2\x9c\x93", "authenticity_token"=>"GalqKSrYuU2l9o2vxo3aWeqf4Xfvy+g5GAWbSXC6pvc=", "user"=>{"email"=>"admin.user@domain.com", "password"=>"[FILTERED]"}, "commit"=>"Login"}\n2014-05-17T08:46:59.957414+00:00 heroku[router]: at=info method=POST path=/users/sign_in host=slapp.herokuapp.com request_id=f58dcf4f-a95f-4280-b0f9-4de593992774 fwd="58.7.233.232" dyno=web.2 connect=2ms service=599ms status=302 bytes=1408\n2014-05-17T08:47:00.223198+00:00 heroku[router]: at=info method=GET path=/ host=slapp.herokuapp.com request_id=ddb2c5cc-0cc1-401b-ae98-b3c84a0fd8f7 fwd="58.7.233.232" dyno=web.1 connect=0ms service=15ms …Run Code Online (Sandbox Code Playgroud) 我想创建一个自定义函数,在其中传入一个表、一个列和值,并计算满足这些条件的所有行。
到目前为止我有
let
fCountif = (tbl as table, col as text, value as any) as number =>
let
select_rows = Table.SelectRows(tbl, each [col] = value),
count_rows = Table.RowCount(select_rows)
in
count_rows
in
fCountif
Run Code Online (Sandbox Code Playgroud)
但是我遇到了各种各样的问题。第一个是调用函数来测试它,当我为表名传入一个字符串时,它会向函数发送一个文字字符串,而不是将其转换为表。这可能只是通过查询编辑器按钮调用它时出现的问题,并且在我的其余 M 代码中使用该函数时应该会自行解决。
第二个是如何将col值传递到[col]函数的部分中。我已经看到了使用脂肪火箭其他例子即[column name] <= col只是不能得到它的工作。
我正在努力了解函数,并且在 vba 中很舒服,所以如果你有任何提示,请大声说出来。这方面的文档很难获得。干杯。
有什么想法我在这个测试中做错了什么吗?
require "rails_helper"
describe "Rep", type: :feature do
scenario "has a Manager and a Region" do
rep = FactoryGirl.create(:rep)
expect(rep.boss.email).to eq("first.last@email.com")
expect(rep.region.name).to eq("NAT")
end
end
Run Code Online (Sandbox Code Playgroud)
给定 Region 的此类
class Region < ApplicationRecord
self.primary_key = "lid"
has_many :reps
end
Run Code Online (Sandbox Code Playgroud)
我已经更改了区域的主键来引用该列lid
FactoryGirl.define do
factory :rep do
lid 1
email 'first.last@email.com'
association :boss, strategy: :build
association :region, factory: :region, strategy: :build
end
factory :boss, class: Rep do
lid 2
email 'rep.manager@email.com'
manager true
association :region, factory: :region, strategy: :build
end
end
Run Code Online (Sandbox Code Playgroud)
现在,当构建工厂中的关联时, …
在Power BI中,我有一个M查询,用于测试列中的值是否等于或等于null.
当我添加语句[Sale.Revenue] <> null我得到一个错误,但它工作正常,[UserRole.Name] = null它工作正常.仅通过删除语句并将其添加回来进行测试.
We cannot convert the value null to type Logical.
这似乎应该工作,但只是无法搞清楚.
add_user_role_group = Table.AddColumn(
join_expand_sale,
"UserRole.Group1",
each (
if [UserRole.Name] = null and
[Sale.Revenue] <> null then
"Group1"
else if Text.Contains([UserRole.Name], "Manager") then
"Group2"
else
"Undefined"
)
)
Run Code Online (Sandbox Code Playgroud)
我确信它显然是明显的:/感谢您对此的看法.
在我看来,我称之为函数
def sum_customer_yearly_revenue(customer_id, year)
sum_customer_yearly_revenue = Sale.sum(:net_amount, :conditions => ['customer_id = ? AND financial_year = ?', customer_id, year])
end
Run Code Online (Sandbox Code Playgroud)
出于某种原因,SQL发送到Postgresql(在日志文件中查看)如下:
SELECT SUM("sales"."net_amount") AS sum_id FROM "sales"
Run Code Online (Sandbox Code Playgroud)
所有条件都被忽略了.
有没有人经历过这个,能给我一些见解吗?
powerbi ×3
m ×2
powerquery ×2
activerecord ×1
dalli ×1
dax ×1
devise ×1
factory-bot ×1
heroku ×1
memcached ×1
postgresql ×1
sql ×1