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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
visualenthusias
New Member

Calculate the Percentage based on the Filter value.

Hello Team,

 

I have a table with the below details and would like to see the percentage as per the selection in list box. 

 

TeamStatus
AWon
BDraw
CLost
AWon
BLost
CDraw
ALost
BWon
CWon
ADraw
BWon
CLost

 

The List Box Will have the option A, B and C and other list box will have Won, Lost and Draw. if we choose A and Won, a Card should display the percentage of A Won and similary for other values. 

1 ACCEPTED SOLUTION
v-rongtiep-msft
Community Support
Community Support

Hi @visualenthusias ,

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

Measure =
VAR _1 =
    SELECTEDVALUE ( 'status'[Status] )
VAR _2 =
    SELECTEDVALUE ( team[Team] )
VAR _re =
    IF (
        _2 = BLANK ()
            && _1 <> BLANK ()
            && _1 = SELECTEDVALUE ( 'Table'[Status] ),
        1,
        IF (
            _2 <> BLANK ()
                && _1 = BLANK ()
                && _2 = SELECTEDVALUE ( 'Table'[Team] ),
            1,
            IF (
                _2 <> BLANK ()
                    && _1 <> BLANK ()
                    && _1 = SELECTEDVALUE ( 'Table'[Status] )
                    && _2 = SELECTEDVALUE ( 'Table'[Team] ),
                1,
                0
            )
        )
    )
RETURN
    _re
Measure2 =
VAR _1 =
    COUNTAX ( ALL ( 'Table' ), 'Table'[Team] )
VAR _2 =
    COUNTAX ( FILTER ( ALL ( 'Table' ), [Measure] <> 0 ), 'Table'[Team] )
RETURN
    _2 / _1

vpollymsft_0-1679294727568.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

3 REPLIES 3
v-rongtiep-msft
Community Support
Community Support

Hi @visualenthusias ,

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

Measure =
VAR _1 =
    SELECTEDVALUE ( 'status'[Status] )
VAR _2 =
    SELECTEDVALUE ( team[Team] )
VAR _re =
    IF (
        _2 = BLANK ()
            && _1 <> BLANK ()
            && _1 = SELECTEDVALUE ( 'Table'[Status] ),
        1,
        IF (
            _2 <> BLANK ()
                && _1 = BLANK ()
                && _2 = SELECTEDVALUE ( 'Table'[Team] ),
            1,
            IF (
                _2 <> BLANK ()
                    && _1 <> BLANK ()
                    && _1 = SELECTEDVALUE ( 'Table'[Status] )
                    && _2 = SELECTEDVALUE ( 'Table'[Team] ),
                1,
                0
            )
        )
    )
RETURN
    _re
Measure2 =
VAR _1 =
    COUNTAX ( ALL ( 'Table' ), 'Table'[Team] )
VAR _2 =
    COUNTAX ( FILTER ( ALL ( 'Table' ), [Measure] <> 0 ), 'Table'[Team] )
RETURN
    _2 / _1

vpollymsft_0-1679294727568.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.

 

visualenthusias
New Member

Hello @amitchandak  - We haev the below error. 

A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

amitchandak
Super User
Super User

@visualenthusias , A new measure

 

calculate(countrows(Table), calculate(countrows(Table), removefilters(Table[Status]) ) )

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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