使用DAX公式将文本显示为值Power Pivot

时间:2018-11-02 11:49:49

标签: excel dax

是否有一种使用DAX度量来创建包含文本值而不是它将自动给出的数字总和/计数的列的方法?

在下面的示例中,名字将显示为值(在第一个表中),而不是名字在第二个表中。

enter image description here

数据表:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    android:id="@+id/root_ID"
    >


    <ImageButton
        android:id="@+id/acceptButtonID"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:background="@drawable/round_button"
        android:elevation="6"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.85"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline_private"
        app:srcCompat="@drawable/ic_delete" />

    <ImageButton
        android:id="@+id/DateButtonID"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:background="@drawable/round_button"
        android:elevation="6dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.15"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline_private"
        app:srcCompat="@drawable/ic_delete" />

    <ImageButton
        android:id="@+id/setButtonID"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:background="@drawable/round_button"
        android:elevation="6dp"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline_private"
        app:srcCompat="@drawable/ic_delete" />

    <EditText
        android:id="@+id/EditTextID"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:gravity="top"
        android:background="@android:color/transparent"
        android:inputType="textMultiLine|textNoSuggestions"
        app:layout_constraintBottom_toTopOf="@+id/guideline_private"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <View
        android:id="@+id/white_view_private"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#fff"
        android:visibility="visible"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline_private" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline_private"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.85"
        />

</android.support.constraint.ConstraintLayout>

2 个答案:

答案 0 :(得分:2)

不需要DAX。您应该将first_name字段放在“行”而不是“值”上。为报告布局选择Tabular View。像这样:

enter image description here

答案 1 :(得分:0)

经过一番搜索,我发现了4种方法。

度量1(如果值不同,将返回空白):

=IF(COUNTROWS(VALUES(Table1[first_name])) > 1, BLANK(), VALUES(Table1[first_name]))

度量2(如果值不同,将返回空白):

=CALCULATE(
VALUES(Table1[first_name]),
FILTER(Table1,
COUNTROWS(VALUES(Table1[first_name]))=1))

小节3(将显示每个文本值),谢谢@ Rory:

=CONCATENATEX(Table1,[first_name]," ")

对于非常大的数据集,此连接似乎更好地工作:

=CALCULATE(CONCATENATEX(VALUES(Table1[first_name]),Table1[first_name]," "))

结果:

enter image description here