powerbidaxpowerbi-desktoppowerbi-custom-visuals

In Power BI need table visual row count using field parameter value selection


I have a Table visual on my dashboard, the columns/fields using a field parameter to select columns dynamically in table visual. The number of rows changes dynamically dependent on user choices, and the user can pick any combination of values in field parameters.

Example:

In my scenario i have 20 columns the user can pick max 5 combination of values in field parameters.

Columns: Customers, Products, Category, Units, Levels, InStock etc If Count when products selected alone If Counts when products & customer where selected If counts any columns selected where need summary count which ever values selected

Need a row count in Card Visual. How many rows appear in the table visual dependent on field parameter selection?


Solution

  • There isn't an easy way to do this. Here is an approach that you can try. It involves adding columns to the table for each column with its value if selected by the user, otherwise just blank. Then we do a SUMMARIZE on the new columns with a COUNTROWS.

    Try the following, and I will leave you to complete it for all the other columns needed.

    Count_Rows2 = 
      var ps = DISTINCT(Parameter[Parameter Fields])
      var tbl = 
        ADDCOLUMNS(
          ledger_fy22_qtr1,
          "_c1", IF(NAMEOF('ledger_fy22_qtr1'[ACCOUNT]) in ps, [ACCOUNT]),
          "_c2", IF(NAMEOF('ledger_fy22_qtr1'[ACCOUNTING_PERIOD]) in ps, [ACCOUNTING_PERIOD]),
          "_c3", IF(NAMEOF('ledger_fy22_qtr1'[FISCAL_YEAR]) in ps, [FISCAL_YEAR]),
          "_c4", IF(NAMEOF('ledger_fy22_qtr1'[OPERATING_UNIT]) in ps, [OPERATING_UNIT])
        )
      RETURN COUNTROWS(
        SUMMARIZE(
          tbl,
          [_c1], [_c2], [_c3], [_c4]
        )
      )