0
votes

I have the following table, called score, on power BI over which I want to apply a group by date:

enter image description here

I have looked into the official documentacion but the examples are rather complex for my use case. I have tried the following:

Columna = GROUPBY(copia_scores;copia_scores[Date];"result";COUNT(CurrentGroup))

But it says that COUNT anly acept a column as input, but if I use a column:

Columna = GROUPBY(copia_scores;copia_scores[Date];"res";COUNT(copia_scores[Date]))

Then it says that the aggregation has to be done with CurrentGroup.

EDIT:

What I'm traying to get a new column with the count of classes by date.
Basically the agregation of the groupby as in the bellow table.

enter image description here

Total_dia has the count of records by day, which is 4 for the 12-02-2018.

I did that in the query editor but I need to do the same in the main windows using DAX.

1
Are you trying to create a new table, a new calculated column, or some sort of measure?Alexis Olson
@AlexisOlson What I'm traying to get a new column with the count of classes by date. Basically the agregation of the groupbyLuis Ramon Ramirez Rodriguez
It automatically does a GROUP BY when you drop that field on the client. The trivial solution is to create a new column which contains a 1, and set it's rollup to SUM. This will give you a (slow) count of records by whatever you drop on the page. Do you want to count records or unique classes? If unique classes then use a DISTINCTCOUNTNick.McDermaid
@Nick.McDermaid I have updated the question which a sample of the table i want.Luis Ramon Ramirez Rodriguez
@AlexisOlson have updated the question which a sample of the table i want.Luis Ramon Ramirez Rodriguez

1 Answers

1
votes

To get total_dia as a calculated column that groups by date summing clase_dia, try this:

total_dia =
CALCULATE(
    SUM(copia_scores[clase_dia]),
    ALLEXCEPT(copia_scores, copia_scores[Date])
)

Note that GROUPBY is a table function. If you used it to create a new table like this

NewTable =
GROUPBY(copia_scores,
    copia_scores[Date],
    "total_dia",
    SUMX(CURRENTGROUP(), copia_scores[clase_dia])
)

Then you'd get a table like this:

copia_scores_Date  total_dia
----------------------------
      12/02/2018          4
      13/02/2018          7
      14/02/2018          1
      15/02/2018          5