Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
SophRow
Resolver II
Resolver II

Measure to calculate a status rate by site name

Hi,

 

I have two columns of data - the first is a status column, the second is site name. 

 

I want to calculate the rate of each status by total number of rows for each site. There are only 4 status's but there are 27 sites! Is there a quick way with DAX to calculate #status divided by total rows for each site, without having to manually create measures for each site?

 

SophRow_0-1675996567573.png

 

Best,

Soph

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SophRow ,

I have created a simple sample, please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR _site =
    CALCULATE (
        COUNT ( 'Table'[site name] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[site name] = SELECTEDVALUE ( 'Table'[site name] )
        )
    )
VAR _status =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[status] = SELECTEDVALUE ( 'Table'[status] )
                && 'Table'[site name] = SELECTEDVALUE ( 'Table'[site name] )
        )
    )
RETURN
    _status / _site

Or a column.

Column =
VAR _site =
    CALCULATE (
        COUNT ( 'Table'[site name] ),
        FILTER ( ALL ( 'Table' ), 'Table'[site name] = EARLIER ( 'Table'[site name] ) )
    )
VAR _status =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[status] = EARLIER ( 'Table'[status] )
                && 'Table'[site name] = EARLIER ( 'Table'[site name] )
        )
    )
RETURN
    _status / _site

 

vpollymsft_1-1676251792269.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
SophRow
Resolver II
Resolver II

Thanks so much for helping Polly!

 

What I'm trying to create is similar to the below to tease out each status per total visits rather than per randomised participant:

 

SophRow_0-1676253587937.png

 

Do you know how I could do that with your measure?

 

Best wishes,

Soph

Anonymous
Not applicable

Hi @SophRow ,

How to  tease out each status per total visits ? Could you please provide some sample data and your desired output?

 

 please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Polly - I figured it out! Thanks again for your help - that measure is awesome

Anonymous
Not applicable

Hi @SophRow ,

I have created a simple sample, please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR _site =
    CALCULATE (
        COUNT ( 'Table'[site name] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[site name] = SELECTEDVALUE ( 'Table'[site name] )
        )
    )
VAR _status =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[status] = SELECTEDVALUE ( 'Table'[status] )
                && 'Table'[site name] = SELECTEDVALUE ( 'Table'[site name] )
        )
    )
RETURN
    _status / _site

Or a column.

Column =
VAR _site =
    CALCULATE (
        COUNT ( 'Table'[site name] ),
        FILTER ( ALL ( 'Table' ), 'Table'[site name] = EARLIER ( 'Table'[site name] ) )
    )
VAR _status =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[status] = EARLIER ( 'Table'[status] )
                && 'Table'[site name] = EARLIER ( 'Table'[site name] )
        )
    )
RETURN
    _status / _site

 

vpollymsft_1-1676251792269.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.