0
1

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 3 years have passed since last update.

Power BI 会計年度始まりの月からグラフを表示させる

Last updated at Posted at 2021-06-29

概要

列の並び変えはMS Doc にも記載されてるけれど、ちょっと悩んだので今後の為にメモ
Power BI Desktop での列による並べ替え

やり方

並び替えをしたい表の軸を元に、新しいテーブルを作る

image.png

newTable
CalendarTable = 
VAR BaseCalendar =
    CALENDAR ( MIN('Mail'[DateTimeReceived]), MAX('Mail'[DateTimeReceived]))
RETURN
    GENERATE (
        BaseCalendar,
        VAR BaseDate = [Date]
        VAR MonthNumber = MONTH ( BaseDate )
        VAR MonthName = FORMAT ( BaseDate, "mmmm" )
        VAR YearMonthName = FORMAT ( BaseDate, "mmm yy" )
        VAR FiscalDate = EDATE(BaseDate, -3)
        VAR FiscalYear = CONCATENATE(FORMAT(YEAR ( FiscalDate ), "yy"), "年度")
        VAR FiscalMonth = CONCATENATE(FORMAT(Month ( FiscalDate ), "mm"), "")
        VAR MonthOrder =  if (MonthNumber<=3, MonthNumber +9, MonthNumber -3)
        RETURN ROW (
            "Month", MonthNumber,
            "月順", MonthOrder
            "FiscalDate", FiscalDate,
            "年度", FiscalYear
        )
    )

月の並びを替え用の列を追加する

VAR MonthOrder =  if (MonthNumber<=3, MonthNumber +9, MonthNumber -3)

会計年度用に、変数追加

"月順", MonthOrder

追加した列を公開

リレーションで、元の軸と、新しいテーブルの軸を設定しておく

image.png

「列で並び替え」で、並び替えを指定

Power BI Desktop での列による並べ替え の通りに。
image.png
ここで、軸を数値にすると、並び替え出来ないことがあったので注意

グラフの軸を、追加した軸に交換

image.png

あとがき

Distinctで一意のテーブルを用意して、その並びを指定しておいたりとかも出来るけど、
上級者の方はどうやってらっしゃるのか見てみたいなぁ

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?