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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Writing an IF statement referencing a column, not a measure

I have a table(Part Number Master) with a column titled "BOM".  The results in that Column is either null or B.

 

I currently have the following measure locted in the Part Number Master table:

Order = (((sum('Part Number Master'[TOTAL DAYS LEAD TIME])/7)+2.8)*'Part Number Master'[Avg Weekly Consumption])-sum('52 Week Consumption'[On Hand])-sum('52 Week Consumption'[On Order])

 

I want to make a change to the measure were if the part number has a "B" in the BOM column, change the formula to "+3.8" instead of the current "+2.8". Something like this:

 

Order = if('Part Number Master'[BOM]="B",  (((sum('Part Number Master'[TOTAL DAYS LEAD TIME])/7)+3.8)*'Part Number Master'[Avg Weekly Consumption])-sum('52 Week Consumption'[On Hand])-sum('52 Week Consumption'[On Order]),(((sum('Part Number Master'[TOTAL DAYS LEAD TIME])/7)+2.8)*'Part Number Master'[Avg Weekly Consumption])-sum('52 Week Consumption'[On Hand])-sum('52 Week Consumption'[On Order]))

 

The problem is when I type =if(.........it will not allow for a column entry, it only allows me to select other "Measures".

 

Basically, if the part number BOM column has a B, I want to order an extra week's worth of inventory.

 

1 ACCEPTED SOLUTION

4 REPLIES 4
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

In addition, using FIRSTNONBLANK Function (DAX) should also work in this scenario. The formula below is for your reference.

Order =
IF (
    FIRSTNONBLANK ( 'Part Number Master'[BOM], 1 ) = "B",
    (
        (
            ( SUM ( 'Part Number Master'[TOTAL DAYS LEAD TIME] ) / 7 )
                + 3.8
        )
            * 'Part Number Master'[Avg Weekly Consumption]
    )
        - SUM ( '52 Week Consumption'[On Hand] )
        - SUM ( '52 Week Consumption'[On Order] ),
    (
        (
            ( SUM ( 'Part Number Master'[TOTAL DAYS LEAD TIME] ) / 7 )
                + 2.8
        )
            * 'Part Number Master'[Avg Weekly Consumption]
    )
        - SUM ( '52 Week Consumption'[On Hand] )
        - SUM ( '52 Week Consumption'[On Order] )
)

 

Regards

Anonymous
Not applicable

Here is the error I am receiving when using your suggestion.  Is this an issue with my database or just with the formula?

 

Capture.PNG

Hi @Anonymous,

 

What data source are you using in this case? Based on my research, the error is returned by the MS SSAS server.

 

Reference:

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ec842da4-2cfa-4f2b-95e3-8627ba18f622/the-operation-was-cancelled-because-of-locking-conflicts?forum=sqlanalysisservices

https://archive.sap.com/discussions/thread/3840305

 

Regards

Greg_Deckler
Community Champion
Community Champion

You need to use an aggregation function, in this case you should be able to use VALUES function.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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