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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Percent of text values in column but determine if equals another measure

Hello! I could use some help with getting a measure to provide a percent of text values of a column but needs determine if it equals another measure. For instance if YES count equals per location then "100%" but if NO equals per location then "0%".  I need a measure that is the percent of yes & no in a single column (percent of grand total won't work). 

 

Current Measures: 

 

 

Countperlocation = CALCULATE ( DISTINCTCOUNT('Table'[ID Number] ), ALLEXCEPT ( 'Table','Table'[Location]) )
Count_YES_Location = CALCULATE( COUNTROWS('Table' ), 'Table'[(Result)] = "YES" , ALLEXCEPT('Table','Table'[Location]))
Count_NO_Location = CALCULATE( COUNTROWS('Table' ), 'Table'[(Result)] = "NO" , ALLEXCEPT('Table','Table'[Location]))

 

 

 

Desired Ouput:

LocationCount per locationResult = YESResult = NOPercentStatus
Location 188 100%
Location 211 100%
Location 322 100%
Location 455 100%
Location 599 100%
Location 61414 100%
Location 744 100%
Location 816 160%
Location 916 160%
Location 1016 160%
Location 1127 270%
Location 1227 270%
Location 1327 270%
Location 142612510%
Location 1527 270%
Location 162932630%

 

ada_result.PNG

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous there was typo

 

PercentStatus = 
VAR __countPerLocation = [Countperlocation]
RETURN
SWITCH ( TRUE(),
  __countPerLocation  = [Count_YES_Location], 1,
  __countPerLocation  = [Count_NO_Location], 0,
  DIVIDE([DistinctCountResults],[CountperLocation])
)

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@Anonymous there was typo

 

PercentStatus = 
VAR __countPerLocation = [Countperlocation]
RETURN
SWITCH ( TRUE(),
  __countPerLocation  = [Count_YES_Location], 1,
  __countPerLocation  = [Count_NO_Location], 0,
  DIVIDE([DistinctCountResults],[CountperLocation])
)

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous try this measure:

 

% = 
VAR __countPerLocation = [Counterperlocation]
RETURN
SWITCH ( TRUE(),
  __countPerLocation  = [Count_Yes_Location] = 1,
  __countPerLocation  = [Count_No_Location] = 0,
   <<your % formula>
)

 

and change the format of this new measure to %.

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hello thanks for the response! I did try your measure but I am getting an error 😕

 

Error Message:
MdxScript(Model) (34, 3) Calculation error in measure 'Table'[PercentStatus]: DAX comparison operations do not support comparing values of type True/False with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.


New Measure: 

PercentStatus = 
VAR __countPerLocation = [Countperlocation]
RETURN
SWITCH ( TRUE(),
  __countPerLocation  = [Count_YES_Location] = 1,
  __countPerLocation  = [Count_NO_Location] = 0,
  DIVIDE([DistinctCountResults],[CountperLocation])
)

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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