Search code examples
powerbidaxmeasure

Count occurrences in time


Working with unemployment data, and I want to count the number of weeks that a client has received benefits during the last 52 weeks.

I have a dataset with many tables which are all connected via the client number in a fact table. In the fact table the client number occurs for every week of the year in one column, another column shows the type of benefits (if any) received in the current week. So I have a long format.

The other two relevant tables contains

A: List of client number appearing only once per client, but no information about benefits received or week number.

B: List of benefits

Tried counting the rows in my fact table while filtering so as only to do so for the specific benefit I am interested in, but I can't make it work so far.

Weeks on benefit A =

CALCULATE(DISTINCTCOUNT(FactDream[DimDreamBorger]); 
DimDreamYdelse[dagpenge] = 1)

sample data

I just need a table showing how many weeks the individual client has received a specific benefit, but I keep getting a total sum of the weeks that all the clients have received the benefit.


Solution

  • Best would be if you add the following measure:

    =CountRows(YourTable)
    

    Put this measure into a chart visual. Then add a filter visual and put your Benefit column into the filter visual.

    This way you can filter after your benefits, which you are interested, and see the result in the chart.