• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Counting number of records in a card from a report in a table view

jutu

Member
Hi. This would be simple enough in Excel but can't find a way in Power BI.
I want to see dynamically if the table view that I've created has increased/decreased and also need it in a card for the report as a requirement. I would appreciate if you can advise how could I get this in Power BI please. Thank you in advance
 
I mean in a table visual that I have created. Don't know if may be creating a column count number/index using DAX may assist me on the purpose?
 
Not quite sure what you need. In general you'd use COUNTROWS().

But it will really depend on your filter context and how your DAX measures are constructed.
For an example, if you use CALCULATE(SUM(),FILTER(ALL(TABLE),Condition)) type construct, you'll need special handling that mirrors filter context of the measure in your COUNTROWS().
 
Sorry if it's not clear. Will try again sorry. I built this tabular table view. I would like to know how many rows that table that I've built has and put it in card. I have COUNTROWS() for each table that I use in a card which I always do to keep an eye on the tables sizes when I extend a table in power query. But I need a card to number how many records has the tabular table that I have created. Is this clearer I hope?
 
Then you need to use SUMMARIZE() etc to give it same grain as the table visual. And count # of rows of the summarized table.
You don't need all the calculated measures. Only sum() of some column to aggregate based on grouping utilized in your table visual.

Ex: If table uses columns from Calendar's date and city dimension's cityname.
Code:
Measure :=
VAR _temp =
    SUMMARIZE (
        RawData,
        DimCity[cityname],
        DimCalendar[Date],
        "Total", SUM ( RawData[ValueColumn] )
    )
RETURN
    COUNTROWS ( _temp )
 
Thank you very much I should try it. Would I stick as another column in the table visual and would it work as card?
 
Hi. I am sorry but I came around to try the your measure today but I don't get it. Sorry for my ignorance but I don't grasp it. Lets say I have the FactDebt table with 2 columns say Previous and Current. How would I apply it from your example to find the number or records of the table visual that I have created? I am sure it is just me but I find it difficult to translate the below;

Code:
Measure :=
VAR _temp =
    SUMMARIZE (
        RawData,
        DimCity[cityname],
        DimCalendar[Date],
        "Total", SUM ( RawData[ValueColumn] )
    )
RETURN
    COUNTROWS ( _temp )
 
I created, as an example to try and follow the above, a table with 2 records as below but it gives me the error that it needs min 2 arguments......

Code:
Full description records# =
Var FullDescriptionTable =
SUMMARIZE(ALL(
   'Semantic FactDebt'[TransactionDescription],
   'Semantic FactDebt'[TransactionTypeKey]))
RETURN
COUNTROWS(FullDescriptionTable)
 
Last edited by a moderator:
SUMMARIZE requires that you supply following.
SUMMARIZE(TableName, Column(s) to group by, "Aggregated column", calculation for aggregation)

You don't have aggregate column in your SUMMARIZE.
 
Yes, I guessed that much but not sure what parameter to use. My problem is that, novel me, I do not know how to apply the below DAX that you kindly offered. Lets say I have a table visual in the report view consisting of 2 fields, say Previous and Current, and need the number of records of that table visual in a card. I have tried to use the below DAX but no success;

Code:
Measure :=
VAR _temp =
    SUMMARIZE (
        RawData,
        DimCity[cityname],
        DimCalendar[Date],
        "Total", SUM ( RawData[ValueColumn] )
    )
RETURN
    COUNTROWS ( _temp )
 
You need to provide sample data and what your visual shows.
I don't know your data model structure and can't help with what info you provided.
 
Hi. I tried to upload a pbix file but it doesn't accept that format. I hope the screenshot helps. Basically, lets say I have a simple table with 2 fields and I want to have the number of records for the attached visual table in a card
1702032629854.png
 
I the above table it would be 4 records so it counts the totals rows not just unique if that makes sense. Thank you for your patience
 
I need to know what the underlying table looks like. Can you upload at least the raw data using Excel spreadsheet?
 
Back
Top