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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
v-rzhou-msft
Community Support
Community Support

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
v-rzhou-msft
Community Support
Community Support

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

@v-rzhou-msft 

 

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.