0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PowerQuery: 乱数系関数を使う時も、遅延評価を意識しないと、乱数として使えなくなっているので注意

Posted at

背景

会社にて、Number.Random() で乱数が生成出来ない。との発言有。
以前使った際は困った記憶がなかったので、現状での対応策の備忘録

対象関数

概要

最適化によって、全行が同一値になってしまう。

詳細は以下記事が分かりやすいと思います。

対応策

上の記事 にあるように、以下を対処する

行ごとの処理(Table.AddColumn)で再評価が行われるようにするにはどうしたらよいか。カレント行を参照すればよいのだ。

具体的には以下太文字のようにする

= Table.AddColumn(変更された型, "Random", each { Number.Random(), _ }{ 0 })

参考

以下の記事をみても、昔は、特に問題なかった様子

あとがき

ちゃんと勉強していかないとこういう時に困っちゃうけど、情報交換出来る仲間や相手がいると解決せず放置、にならなくてありがたいなぁと改めて思いました。
会社で如何に情報共有の仕組みを作るかって大切ですね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?