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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to calculate the percentage using a constant value

Hello all,

I would want to display top 10 values while retaining the percentage to be calculated over 365 and not over the total of top 10. Hope I am able to convey my query and can get a resolution from this community.

nikhila_0-1649881824435.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

If you want to show Total by all table when you using TopN function in your visual, you can try HASONEVALUE function and IF to create a measure.

My Sample: 

RicoZhou_0-1650272469732.png

Measures:

M_Value = 
IF (
    HASONEVALUE ( 'Table'[Origin] ),
    CALCULATE ( SUM ( 'Table'[Value] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Date] ) )
)
Percentage% = 
VAR _VALUE =
    CALCULATE ( SUM ( 'Table'[Value] ) )
VAR _TOTAL =
    CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Date] ) )
RETURN
    IF ( HASONEVALUE ( 'Table'[Origin] ), DIVIDE ( _VALUE, _TOTAL ), 1 )

Result is as below.

RicoZhou_1-1650272510684.png

 

Best Regards,
Rico Zhou

 

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
Anonymous
Not applicable

Hi @Anonymous ,

 

If you want to show Total by all table when you using TopN function in your visual, you can try HASONEVALUE function and IF to create a measure.

My Sample: 

RicoZhou_0-1650272469732.png

Measures:

M_Value = 
IF (
    HASONEVALUE ( 'Table'[Origin] ),
    CALCULATE ( SUM ( 'Table'[Value] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Date] ) )
)
Percentage% = 
VAR _VALUE =
    CALCULATE ( SUM ( 'Table'[Value] ) )
VAR _TOTAL =
    CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Date] ) )
RETURN
    IF ( HASONEVALUE ( 'Table'[Origin] ), DIVIDE ( _VALUE, _TOTAL ), 1 )

Result is as below.

RicoZhou_1-1650272510684.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@Anonymous 

 

Thankyou for your solution.

I tried your approach. But , below is my output.

nikhila_0-1651168323118.png

I modified the formula as below:

 

Percentage% =
VAR _VALUE =
CALCULATE ( COUNT('data'[passengerid]), 'data'[Arr/Conn/Dep] = "Arriving", 'data'[adhocplanned] = "ad-hoc" )
VAR _TOTAL =
CALCULATE (COUNT('data'[passengerid]), 'data'[Arr/Conn/Dep] = "Arriving", 'data'[adhocplanned] = "ad-hoc", ALLEXCEPT ( 'data','data'[Year-Month] ) )
RETURN
IF ( HASONEVALUE ( 'data'[origin airport] ), DIVIDE ( _VALUE, _TOTAL ), 1 )
MFelix
Super User
Super User

Hi @Anonymous ,

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors