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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
benqpbi
Helper I
Helper I

calculate value based on another column set of values

i have calculated my percentage by using this calculation 

 

Measure = DIVIDE(CALCULATE(SUM('Table Name'[comp_record])),CALCULATE(SUM('Table Name'[comp_record]),ALL('Table Name'))
 
now i have a column named level which has many values but i want to only calculate the above measure for level 4,5,6 only else blank 
benqpbi_0-1681118133127.png

 

3 REPLIES 3
danextian
Super User
Super User

Hi @benqpbi 

 

The measures below change the filter context in your denominator

=
//shows the value each for 4 or 5 or 6

CALCULATE (
        SUM ( 'Table Name'[comp_record] ),
        FILTER ( 'Table Name', 'Table Name'[Level] IN { 4, 5, 6 } )
    )
=
//shows the total value 4, 5 and 6 regardless of filter applied to table 'Table Name'[Level]

CALCULATE (
        SUM ( 'Table Name'[comp_record] ),
        FILTER ( ALL ( 'Table Name'[Level] ), 'Table Name'[Level] IN { 4, 5, 6 } )
    )
=
//shows the total value 4, 5 and 6 regardless of filter applied to table 'Table Name'

CALCULATE (
        SUM ( 'Table Name'[comp_record] ),
        FILTER ( ALL ( 'Table Name' ), 'Table Name'[Level] IN { 4, 5, 6 } )
    )

 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

hello, thank you

i have a doubt how it would calculate the percentage because i need to first calculate the percentage by using this 

Measure = DIVIDE(CALCULATE(SUM('Table Name'[comp_record])),CALCULATE(SUM('Table Name'[comp_record]),ALL('Table Name')) 

then ony calculate the percentage only for level 3,4,5

Hello, my suggestions were only for the denominator which is the second argument in your divide formula. Alternatively, you can modify your formula to show the value only if it meets a certain condition

=
IF (
    SELECTEDVALUE ( 'Table Name'[Level] ) IN { 4, 5, 6 },
    DIVIDE (
        SUM ( 'Table Name'[comp_record] ),
        CALCULATE ( SUM ( 'Table Name'[comp_record] ), ALL ( 'Table Name' ) )
    )
)

 

Answers provided are based on the information provided. You can provide more details - sample data and expected result https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/3175712#M1071... 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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