cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ValentinB
Frequent Visitor

Calculating DAX Measure (% Deviation) using Name Slicer Value

Good day all,

 

I am trying to wrap my head around an issue and can't seem to figure it out. Also tried searching different topics and either it didn't work or I didn't understand something in full.

 

I have created the following Measure:

 

Fuel per Hour =
VAR Total_Trip_Time =
SUMX(
Flight_Indicators,
HOUR(Flight_Indicators[Actual Trip TIme]) + MINUTE(Flight_Indicators[Actual Trip TIme])/60 + SECOND(Flight_Indicators[Actual Trip TIme])/3600)

VAR Total_Trip_Time_INT =
TRUNC(Total_Trip_Time,2)

VAR Total_Trip_Fuel =
CALCULATE(
SUMX(Flight_Indicators,
Flight_Indicators[Block fuel at TOGA push KG] - Flight_Indicators[Block fuel at TD KG]),
FILTER(Flight_Indicators, Flight_Indicators[Block fuel at TOGA push KG] > 0))
RETURN
DIVIDE(Total_Trip_Fuel, Total_Trip_Time_INT)

 

In terms of "Slicers", I have a Name Slicer and a Date Slicer

 

Using the "Card" Visualization I have shown

1) First Card: Amount of fuel/hour based on individual selection from Name Slicer for given Date

2) Second Card: Amount of fuel / hour for given Date (basically "company" value, Name Slicer does not affect this card due to "Edit Interactions" feature)

 

The measure that I am trying to solve is to find the % Deviation of the individual vs company. I've tried using combinations of CALCULATE with SELECTEDVALUE or FILTER but don't seem to figure it out.

 

Any information and guide towards the right direction is very much appreciated and I will be happy to give more information if needed

 

I have also attached an image with the model of the pbix

 

Model.PNG

 

 

 

1 ACCEPTED SOLUTION
Eyelyn9
Community Support
Community Support

Hi @ValentinB ,

 

I have built a simple data sample:

Eyelyn9_0-1640660451952.png

individual = SUM('Table'[Hour]) 
company = CALCULATE(SUM('Table'[Hour]),REMOVEFILTERS('Table'[Name]))
% Deviation = ( [individual]-[company]) / [company]

 

Output:

Eyelyn9_1-1640660521357.png

 

 

If you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

 

Best Regards,
Eyelyn Qin
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

4 REPLIES 4
Eyelyn9
Community Support
Community Support

Hi @ValentinB ,

 

I have built a simple data sample:

Eyelyn9_0-1640660451952.png

individual = SUM('Table'[Hour]) 
company = CALCULATE(SUM('Table'[Hour]),REMOVEFILTERS('Table'[Name]))
% Deviation = ( [individual]-[company]) / [company]

 

Output:

Eyelyn9_1-1640660521357.png

 

 

If you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

 

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

Hello @Eyelyn9 ,

 

Many thanks for your help, indeed it worked on my side as well. Was not fully aware of the "REMOVEFILTER" function but I am glad I've learned something new.

 

Best wishes and Happy Holidays !

amitchandak
Super User
Super User

@ValentinB , As you want selectedvalue as a benchmark, you need an independent table

 

So you need an independent company name table and use that in a measure to get that companies value and this should interact with visual

 

Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Hello @amitchandak ,

 

I have accepted as a solution @Eyelyn9 method since it worked but I will also check and try to implement your part as I am on a learning curve regarding PowerBi and every intel is a good chance to develop more skills and methods.

 

Many thanks as well for your reply and wish you also Happy Holidays.

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors