Forum Discussion

Dhjlm's avatar
Dhjlm
Frequent Visitor
5 years ago
Solved

Help with distinct count in a new table

I need a distinct count of "Sandningsnr" per "Kst" and "Month" in a new table.

 

When I try to do it I can only count "Sandningsnr" per "Kst" or "Month", not both.

 

Any suggestions?

 

 

  • Hi,

     

    as amitchandak says:
    You can create a table like:

    CalculatedTable = 
    Summarize(
        Table1,
        Table1[Sandningsnr],
        Table1[Kst],
        Table1[Month],
        ,"@Count" , countrows(Table1)
    )


    Take care. 

5 Replies

  • Dhjlm , I do not see any month column.

     

    You can have measure like

    countrows(summarize(Table,[Sandningsnr],[per Kst]))

     

    table like summarize(Table,[Sandningsnr],[per Kst])

  • Dhjlm's avatar
    Dhjlm
    Frequent Visitor

    There is a month column in my table (not in picture).

     

    Yes I can use summarize, but not on both "Kst" and "Month"

  • Dhjlm ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

  • Hi,

     

    as amitchandak says:
    You can create a table like:

    CalculatedTable = 
    Summarize(
        Table1,
        Table1[Sandningsnr],
        Table1[Kst],
        Table1[Month],
        ,"@Count" , countrows(Table1)
    )


    Take care. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Dhjlm,

    I think you can use summarize or group by functions to summary your table and use these categories that you want to as group fields, then you can add a custom expression field to count the values of the field based on the current group.

    Regards,

    Xiaoxin Sheng