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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.