简体   繁体   English

创建一个返回多列 Power BI 的度量

[英]Create a measure that returns multiple columns Power BI

measure_test =
SWITCH (
    TRUE ();
    SELECTEDVALUE ( menu[option] ) = "1"; SUM ( table[INSCRITOS] );
    SELECTEDVALUE ( menu[option] ) = "2"; SUM ( table[INSCRICOESCOMPLETAS] );
    SELECTEDVALUE ( menu[option] ) = "3"; SUM ( table[PAGARAMINSCRICAO] );
    SELECTEDVALUE ( menu[option] ) = "4"; SUM ( table[AVALIADOS] );
    SELECTEDVALUE ( menu[option] ) = "5"; SUM ( table[CONVOCADOS] );
    SELECTCOLUMNS (
        table;
        "a"; SUM ( table[CONVOCADOS] );
        "b"; SUM ( table[AVALIADOS] )
    )
)

But, if no option is selected, I want to show all results.但是,如果没有选择任何选项,我想显示所有结果。

What would a measure look like that would show all other measures?显示所有其他度量的度量是什么样的? When selection one:选择一时:

一

When nothing is selected, need to show everyone:当什么都没有选择时,需要向大家展示:

全部

I can't think of any way to achieve the exact result you are looking for.我想不出任何方法来实现您正在寻找的确切结果。 However, you can get to a close enough result using Bookmarks.但是,您可以使用书签获得足够接近的结果。 You would have to create two tables, one displaying "measure_test" (display one measure at a time) and another table displaying all the measures.您必须创建两个表,一个显示“measure_test”(一次显示一个度量),另一个表显示所有度量。 Then create the following Bookmarks:然后创建以下书签:

Bookmark1 --> Hide Table2 and Display Table1
Bookmark2 --> Hide Table1 and Display Table2

You can place the tables in such a way that, it looks like the same table.您可以将桌子放置在看起来像同一张桌子的地方。 Now you can create two buttons, one for single selection and other for All measures and assign the bookmarks accordingly.现在您可以创建两个按钮,一个用于单选,另一个用于所有小节,并相应地分配书签。

Button1 --> your selections will become active and you can select any single measure. 
Button2 --> your selections won't be active and it will display all measures. 

This method will not allow you to do multiple selections.此方法不允许您进行多项选择。 I understand this may not be the perfect solution, but it might just do the trick for your specific scenario.我知道这可能不是完美的解决方案,但它可能只是针对您的特定情况。 Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM