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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
NJ81858
Helper IV
Helper IV

Matrix Measure

Hello,

 

I have a matrix that has Teams as the first level of the matrix, and then the number of times they asked a customer about a promotion, with the values being a count of transaction, broken into "Yes" and "No", and then a percentage, where the percentages within each team are the percent of the total responses for the team, and then the total percentage is the total transactions per team divided by the overall total of transactions. 

NJ81858_1-1684441370673.png

The issue with this matrix is that the 5th team isn't calculating correctly for the percentages. My measure to calculate the percentage is:

 

Percent Measure = 

VAR _each = CALCULATE ( COUNT ( 'Table'[Transaction ID]), FILTER('Table', [Promotion?] = [Promotion]))
VAR _total = CALCULATE ( COUNT ( 'Table'[Transaction ID]), ALL('Table'[Promotion?]))
VAR _overalltotal = CALCULATE ( COUNT ( 'Table'[Transaction ID]), ALLEXCEPT('Table', 'Table'[Date], 'Table'[Transaction Status]) )

RETURN
IF ( HASONEVALUE('Table'[Promotion?]), DIVIDE(_each, _total), DIVIDE(_total, _overalltotal))

 

My measure works perfectly normal for all values except for that one team and I am not sure where I am going wrong. Thank you in advance!

 

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Does it work when you replace HASONEVALUE() with HASONEFILTER()?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
MFelix
Super User
Super User

Hi @NJ81858,

 

You issue is with the formula for the HASONEVALUE part, since team 5 only has one promotion and it's values is yes instead of picking up the 0 it's picking up 1/122 then the result is the same for the line of the no and for the line of the team 5, try the following code:

 

 

Percent measure = 
VAR _each =
    CALCULATE (
        COUNT ( 'Table'[Transaction ID] ),
        FILTER ( 'Table', [Promotion?] = [Promotion] )
    )
VAR _total =
    CALCULATE ( COUNT ( 'Table'[Transaction ID] ), ALL ( 'Table'[Promotion?] ) )
VAR _overalltotal =
    CALCULATE (
        COUNT ( 'Table'[Transaction ID] ),
        ALLEXCEPT ( 'Table', 'Table'[Date], 'Table'[Transaction Status] )
    )
RETURN
    IF (
        ISFILTERED( 'Table'[Promotion?] ),
        DIVIDE ( _each, _total ),
        DIVIDE ( _total, _overalltotal )
    )

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.