【问题标题】:MS PowerApps, If after Switch in powerapps, so it's executed independently (after switch, not inside)MS PowerApps,如果在powerapps中切换后,那么它是独立执行的(切换后,不在里面)
【发布时间】:2019-06-30 16:20:45
【问题描述】:

我的 PowerApps 功能有问题,我无法自行解决。 您可以在下面找到一个有效的代码(尽管我认为它没有得到很好的优化)。与主题一样,if 条件在 switch 内部执行,作为它的参数之一,而不是在 switch 之后执行。最终结果应该是:用户按下按钮,在桌子上应用过滤器,然后如果条件进入播放,就可以了。

主要部分是 if 条件,当用户在下拉菜单中选择条件时,条件按名称或等级对表格进行排序。在该条件下,有支持搜索引擎和排序升序/降序按钮的功能。 之后,我想添加对过滤器按钮的支持,并且按钮本身工作正常,但是 if 条件仅在按下最后一个按钮时执行(因此,例如,当我按下与 It 相关的按钮时,它将类别设置为“1”并且导航到下一个屏幕,但搜索/排序不起作用)。 我尝试用更多括号分隔条件,在 switch 末尾添加“;;”,但它没有解决问题(另外破坏了应用程序)。

Switch(
    category;
    1;
    Filter(
        Table1_2;
        '4. Area of training' = "IT-related"
    );
    //here is a bunch of filters for categories from 2 to 4
    5; //no filter as it should display table without any filter
If( //the problematic if, that is executed only when category is "5"
        dropdown_sort.Selected.Value = "Name of the training"; //check what the value of dropdown is, and the execute positive or negative case
        SortByColumns(
            Search(
                Table1_2;
                search_engine.Text; //takes text input and searches inside column below
                "3_x002e__x0020_Name_x0020_of_x0020_the_x0020_training"
            );
            "3_x002e__x0020_Name_x0020_of_x0020_the_x0020_training"; //sorting on this column
            If( //to change ascendin/descending on button press
                sort;
                Ascending;
                Descending
            )
        );
        //here is second part of if, that is basically identical to above (it sorts different column), and executes case when selected value of dropdown is different that "Name..."
    )
)

无论切换如何,我都想执行 if。此外,如果有更好的方法,请写下您的建议。谢谢。

【问题讨论】:

  • 我的大部分观察你已经知道了,但还是让我试着把它说出来。在您当前的 switch case 代码中,If 语句显然在您的 switch 内部,并且对于 category =5 也是如此,因此它仅针对 5 的类别触发。您在此处尝试实现的目标称为“链接操作”。正如您已经尝试过的那样;;这并没有帮助,不如简单地尝试一下;也看看这个链接它会给你更多的想法,让我知道这是否有帮助。 powerusers.microsoft.com/t5/General-Discussion/…
  • 我重新安排了一段代码以满足我的要求并设法让它工作(不幸的是,以愚蠢的方式)。以后我会试试你的建议。

标签: function powerapps multiple-conditions


【解决方案1】:

这可能不是最终答案,但根据我阅读的内容,我将尝试以下内容。

if( category=1;
    Filter(
        Table1_2;
        '4. Area of training' = "IT-related"
    );;If( //the problematic if, that is executed only when category is "5"
        dropdown_sort.Selected.Value = "Name of the training"; //check what the value of dropdown is, and the execute positive or negative case
        SortByColumns(
            Search(
                Table1_2;
                search_engine.Text; //takes text input and searches inside column below
                "3_x002e__x0020_Name_x0020_of_x0020_the_x0020_training"
            );
            "3_x002e__x0020_Name_x0020_of_x0020_the_x0020_training"; //sorting on this column
            If( //to change ascendin/descending on button press
                sort;
                Ascending;
                Descending
            )
        );
        //here is second part of if, that is basically identical to above (it sorts different column), and executes case when selected value of dropdown is different that "Name..."
    )
    category=2;
    Filter(
        Table1_2;
        '4. Area of training' = "IT-related"
    );;If( //the problematic if, that is executed only when category is "5"
        dropdown_sort.Selected.Value = "Name of the training"; //check what the value of dropdown is, and the execute positive or negative case
        SortByColumns(
            Search(
                Table1_2;
                search_engine.Text; //takes text input and searches inside column below
                "3_x002e__x0020_Name_x0020_of_x0020_the_x0020_training"
            );
            "3_x002e__x0020_Name_x0020_of_x0020_the_x0020_training"; //sorting on this column
            If( //to change ascendin/descending on button press
                sort;
                Ascending;
                Descending
            )
        );
        //here is second part of if, that is basically identical to above (it sorts different column), and executes case when selected value of dropdown is different that "Name..."
    )
    //here is a bunch of filters for categories from 2 to 4
    category=5;  

)

【讨论】:

    【解决方案2】:

    与此同时,我设法自己解决了这个问题,类似于您的建议。错误值和其他类别的代码相同。无论如何,感谢您的帮助。

    Switch(
        category;
        1;
        If(
            dropdown_sort.Selected.Value = "Name of the training";
            SortByColumns(
                Search(
                    Filter(
                        Table1_2;
                        '4. Area of training' = "IT-related"
                    );
                    search_engine.Text;
                    "3_x002e__x0020_Name_x0020_of_x0020_the_x0020_training"
                );
                "3_x002e__x0020_Name_x0020_of_x0020_the_x0020_training";
                If(
                    sort;
                    Ascending;
                    Descending
                )
            );
    
    

    【讨论】:

      猜你喜欢
      • 2021-10-23
      • 1970-01-01
      • 2022-06-22
      • 1970-01-01
      • 2021-01-05
      • 1970-01-01
      • 1970-01-01
      • 2022-10-12
      • 1970-01-01
      相关资源
      最近更新 更多