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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ofoster
Frequent Visitor

Conditional measure producing blanks when based on other measures, need to give a value

Hello,

 

I'm trying to build a conditional model. In this model, I am trying to output a measure (in this case one of 6 pre-calculated measures) based on conditions that can be changed via two slicers. There is no connection between the slicers, so they are influencing each other (they do not connect in the model view and both are set to no interactions with anything in this BI except this one card).

 

I have checked my intermediate steps to make sure that they are not blank. Everything works on it's own until I combine them together. I've had a coworker check those intermediate steps and they calculate correctly with a General format (we've tried converting them to different data types, including text, with no success).

 

Here is my measure calculation:

% Diff LH W/WO Fuel/LB = IF(OR(AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2020, SELECTEDVALUE('Shippy'[Shippy Date].[Year])= 2021), AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2021, SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2020)), 'Order Info'[20-21 Diff LH w/wo fuel/lb],
    IF(OR(AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2020 , SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2022) , AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2022,SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2020)), 'Order Info'[20-22 Diff LH w/wo fuel/lb],
        IF(OR(AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2020 ,SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2023) , AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2023,  SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2020)), 'Order Info'[20-23 Diff LH w/wo fuel/lb],
            IF(OR(AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2021 ,SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2022) , AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2022 , SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2021)), 'Order Info'[21- 22 Diff LH w/wo fuel/lb],
                IF(OR(AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2021 ,SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2023) , AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2023 , SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2021)), 'Order Info'[21- 23 Diff LH w/wo fuel/lb],
                    IF(OR(AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2022, SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2023) , AND(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = 2023, SELECTEDVALUE('Shippy'[Shippy Date].[Year]) = 2022)), 'Order Info'[22- 23 Diff LH w/wo fuel/lb],
                    IF(SELECTEDVALUE('Ship Date'[Ship Date].[Year]) = SELECTEDVALUE('Shippy'[Shippy Date].[Year]), "No Change",
                        0)))))))
 
Picture for clarity:
ofoster_3-1684520812693.png

 

 
Here is what we get with the following conditions:
ofoster_0-1684520285972.png

Any combination of unequal years give us this Blank. So for example for 21 vs 22 it needs to produce either a 0.3 or 30%.

 

When the years match, we get the correct output:

ofoster_1-1684520684558.png

 

 And anything else produces what we want (I will be changing this to Blank at a later date, this is just so I can differentiate different circumstances):

ofoster_2-1684520767763.png

 

Thank you for your help.

 

EDIT (5/22/23):

Below is a sample dataset called Order Info.

Order IDShip DateWeightLinehaul ChargesTotal Fuel Surcharges
13/12/2020230105.514.46
24/16/2020230101.233.45
36/28/2020109111.512.18
47/6/20201919236.17197.12
512/4/2020265075018.87
63/12/20212128750118.4
74/16/20211992171.9733.36
86/28/20211685263.9722.55
97/6/20211992602.3536.06
1012/4/202114160888.2534
113/12/2022800241.9419.77
124/16/202214332945.6223.22
136/28/202210990.113.7
147/6/2022280002314.2633.65
1512/4/20221521237.8574.66
163/12/2023291771775.563.11
174/16/20235024560.1358.31
186/28/2023690804.915.76
197/6/20231432457.5122.61
2012/4/2023916750577.02

 

For some of the formuli, they reference a selected value found in Net Fuel:

Charge Analysis
LH

LH + Fuel

 

Here are some of the other referenced formulas (NOTE: some of the measures below are repeated several times in the above formula with small alterations, so I'll only be writing it down once for the main structure. I'll mark the repeated and altered measures with a ** at the beginning):


Calculated Columns:

LH + Fuel = 'Order Info'[Linehaul Charges] + 'Order Info'[Total Fuel Surcharges]
 
Measures:
LH W/WO Fuel = IF(SELECTEDVALUE('Net Fuel'[Charge Analysis]) = "LH", SUM('Order Info'[Linehaul Charges]), SUM('Order Info'[LH + Fuel]))
LH W/WO Fuel/LB = DIVIDE('Order Info'[LH W/WO Fuel], SUM('Order Info'[Weight]))
** 2020 LH W/WO Fuel/LB = CALCULATE(DIVIDE('Order Info'[LH W/WO Fuel], SUM('Order Info'[Weight])), FILTER('Ship Date', 'Ship Date'[Ship Date].[Year] = 2020))
** 20-21 Diff LH w/wo fuel/lb = ('Order Info'[2021 LH W/WO Fuel/LB] - 'Order Info'[2020 LH W/WO Fuel/LB])/'Order Info'[2020 LH W/WO Fuel/LB]

 

1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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