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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
v-eqin-msft
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
v-eqin-msft
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 @v-eqin-msft ,

 

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

Hello @amitchandak ,

 

I have accepted as a solution @v-eqin-msft 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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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