如何在“标题”中分配变量

时间:2019-01-21 12:06:00

标签: powerquery m

我有“报告”,其中日期作为列标题。

该报告设置为“显示最近的x周”,因此该日期应每星期偏移7天,但由于PowerQuery将标头名称作为常量固定在代码中,因此不会引起更新,因此会引起问题。

因此,本周报告应以10/12/18日期范围开头,并以19/02/19结尾。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/dashboard_title_bg">

<TextView
    android:id="@+id/actionBarCentralTextView"
    style="@style/MainTitleActionBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.6" />

<ImageButton
    android:id="@+id/btActionBarMenuText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="16dp"
    android:background="?android:selectableItemBackground"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.6" />

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/back_container_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.6">

    <ImageButton
        android:id="@+id/btActionBarNotificationsText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:background="?android:selectableItemBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/tvSecondTitleText"
        style="@style/SecondaryTitleActionBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

1 个答案:

答案 0 :(得分:1)

一种方法是更改​​此行:

Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Project Location Name", "Role Name", "03/12/2018", "10/12/2018", "17/12/2018", "24/12/2018", "31/12/2018", "07/01/2019", "14/01/2019", "21/01/2019", "28/01/2019", "04/02/2019", "Total"}, {"Project Location Name", "Role Name", "03/12/2018", "10/12/2018", "17/12/2018", "24/12/2018", "31/12/2018", "07/01/2019", "14/01/2019", "21/01/2019", "28/01/2019", "04/02/2019", "Total"})

收件人:

let
    headersToExpand = List.Distinct(List.Combine(List.Transform(#"Converted to Table"[Column1], Record.FieldNames))),
    expandDynamically = Table.ExpandRecordColumn(#"Converted to Table", "Column1", headersToExpand)
in
    expandDynamically

假设:

  • "Column1"中的每一行都包含records
  • 您之前的“步骤”是#"Converted to Table"
  • 要扩展的记录列称为"Column1"

然后,headersToExpand位应该为您提供一个list唯一的记录字段名称(而不是您具有的硬编码的list),然后可以在{{ 1}}步骤。