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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
mfriedrich228
Regular Visitor

Value of measure is always 1,00 instead of calculating portion of amount of answers per year

Hi everyone,

I have the following table structure:

TeamYearVotecount    QuestionAnswer
Development  2021  1Do you like your job?                           Yes
Development20211Do you like your job?Yes
Development20211Do you like your job?No
Development20211Are you happy with your salary?Yes
Development20201Are you happy with your salary?No
Development20191Are you happy with your salary?No

Now what I would like to do in a bar chart is to display the percentage of every answer per year of the total per year. So for the first question it should be ~66,66% for "Yes" in the year 2021 and ~33,33% for "No". I can't use the build in Power BI function to calculate my percentage values since that is looking at all answers of all 3 years then calculates the percentages of that.  I have a measure that surprisngly when I don't sort the table at all, but breaks as soon as I need to sort it:

 

Vote % = 
Divide(
   count( [Answer] ),
   Calculate(
        count( [Answer] ),
        all( 'Survey'[Team] ),
        all( 'Survey'[Answer] )
   )
)

 

Maybe someone of you sees or knows what I might do wrong or if there is a better alternative for doing that, thanks for your time!

Kind regards

Maximilian

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

Test this:

Vote % =

Divide(
count( [Answer] ),
Calculate(
count( [Answer] ),
REMOVEFILTERS('answer%'[answer],'answer%'[Team])
)
)

In my tests sort didn't affect this measure. I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!





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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

Instead of removing the filter context on specific columns, another option is specify which columns to keep in the filter context using ALLEXCEPT. This removes the filter context on all columns except the ones you specify.

 

For example,

Vote % =
DIVIDE (
    COUNT ( 'Survey'[Answer] ),
    CALCULATE (
        COUNT ( 'Survey'[Answer] ),
        ALLEXCEPT ( 'Survey', 'Survey'[Year], 'Survey'[Question] )
    )
)

 

PaulOlding
Solution Sage
Solution Sage

Hi @mfriedrich228 

 

As ValterriN said I don;t see how sorting can affect a measure.  Hopefully his suggested DAX works for you.

 

It's possible to visualise this without any DAX.  You can use the 100% Stacked Column Chart and a slicer on Year to get your answer.

PaulOlding_0-1643378896085.png

 

ValtteriN
Super User
Super User

Hi,

Test this:

Vote % =

Divide(
count( [Answer] ),
Calculate(
count( [Answer] ),
REMOVEFILTERS('answer%'[answer],'answer%'[Team])
)
)

In my tests sort didn't affect this measure. I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!





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

Proud to be a Super User!




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors