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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filter Context not propagating with IF function used in a measure

Hi All,

 

Having an issue with a basic IF logic used in a measure. My IF statement is as follows:

 

Volume Check = 
IF(
    [Volume] > 10000,
    "Flag",
    "Ok"
)

 

 

The measure works and my table visual does what I want:

Project NameLaunch DateProject NumberVolume Check
A10/15/202012345Ok
B1/5/202524690Ok
C4/7/202449380Flag
D4/1/202498760Ok
E4/10/202319752Ok
F4/8/202439504Ok
G4/3/202379008Flag

 

My issue occurs when I drag a field into the table visual from one of my other lookup tables. Example: if I drag in the "Business Name" field from the Business table it repeats everything like you would see if a relationship did not exist between lookup and source tables. The table looks as follows:

BusinessProject NameLaunch DateProject NumberVolume Check
Business 1A10/15/202012345Ok
Business 2A10/15/202012345Ok
Business 3A10/15/202012345Ok
Business 1B1/5/202524690Ok
Business 2B1/5/202524690Ok
Business 3B1/5/202524690Ok
Business 1C4/7/202449380Flag
Business 2C4/7/202449380Flag
Business 3C4/7/202449380Flag
Business 1D4/1/202498760Ok
Business 2D4/1/202498760Ok
Business 3D4/1/202498760Ok
Business 1E4/10/202319752Ok
Business 2E4/10/202319752Ok
Business 3E4/10/202319752Ok
Business 1F4/8/202439504Ok
Business 2F4/8/202439504Ok
Business 3F4/8/202439504Ok
Business 1G4/3/202379008Flag
Business 2G4/3/202379008Flag
Business 3G4/3/202379008Flag

 

The issue is not my data model. I believe I need to force the filter context with my IF measure. Does anyone know what I am doing wrong here and how I can fix this issue? Thank you!

1 ACCEPTED SOLUTION

@Anonymous 

You can modify your measure

Volume Check =
IF ( [Volume] > 10000, "Flag", IF ( [Volume] > 0, "Ok" ) )

or

 

Volume Check =
IF ( NOT ISBLANK ( [Volume] ), IF ( [Volume] > 10000, "Flag", "Ok" ) )

View solution in original post

11 REPLIES 11
tamerj1
Super User
Super User

@Anonymous 

When adding columns from different tables the engine creates a cross join table generating all possible unique combinations. Allways add columns as measures perhaps using SELECTEDVALUE 

Anonymous
Not applicable

Hi @tamerj1 

 

Thank you for the response! What would the DAX look like for this combined with my measure above?

It depends on your data model. Can you please share a screenshot of you data model and the expected results table indicating the the table to which each column belongs. 

Anonymous
Not applicable

Hi @tamerj1 

 

Below is a screenshot of the data model and the desired result. The measure I am trying to create is currently stored in a Measure Table to keep things organized in the fields pane (screenshot provided) but the expression [Volume] in my formula above is calculated from the "Activity Metrics Detail" table.

Data ModelData Model

 

Desired ResultDesired Result

 

Measure TableMeasure Table

 

Thank you!

Hi @Anonymous 

Yes you are 100% correct. But you also have to account for the changes in the filter context every time you add a column to the visual. Here are some screen shots of a similar data model

1.png2.png3.png

Anonymous
Not applicable

Hi @tamerj1 

 

Great explanation and I appreciate the diagram. We're on the same page that fact tables cannot filter dimensions and, dimensions can filter fact tables. There's no confusion around that. The way my measure is built is the issue because when I add Project ID, Business ID, and Date ID in a table and then add a slicer to slice by, let's say, Business Name, it filters perfectly. The issue occurs when I add fields from different dimensions in addition to my Volume Check measure.

 

This is how I always structure my data models and my measures work fine. I have never used an IF logic before which is why I think it's missing something.

 

How do I fix the measure to work correctly?

@Anonymous 

I don't think IF has anything to do with that. Place the measure [Volume] in the table and see what values you get. 
again by placing a filter from another dim table you have changed the filter context. The values of the comparison measure will be diffrent (less) 

Anonymous
Not applicable

Hi @tamerj1 

 

Everything works as expected. I created a table to test by placing Project Number, Business Unit, and Launch Year (all fields from my dimensions) along with my Volume measure and filter context works as it should.

 

For reference, below is the calculation for Volume. One thing to note is that I like to branch my measures, so the "MASTER TOTAL" measure is simply a SUM of the values column in my fact table.

 

Volume =

CALCULATE(

      [MASTER TOTAL],

      'Activity Metrics Detail'[Line Item] = "Volume"

)

@Anonymous 

You can modify your measure

Volume Check =
IF ( [Volume] > 10000, "Flag", IF ( [Volume] > 0, "Ok" ) )

or

 

Volume Check =
IF ( NOT ISBLANK ( [Volume] ), IF ( [Volume] > 10000, "Flag", "Ok" ) )

@Anonymous 

Business table has no relationship with projects. Adding the business number column has no meaning based your data model. If you remove it then the lookup 'Projects' table can safely filter the fact table otherwise a meaningless crossjoin table will be creared. Do you have any coulmns that can porovide a direct connections between the two tables?

Anonymous
Not applicable

Hi @tamerj1 

 

I am not sure I understand what you mean. Each business is involved with many projects. The project, and therefore the business, will create facts based on events that take place over time. The reason I have created lookup tables for projects and business is to optimize the data model using the start schema method.

 

Project Number is found in both the Project table (dimension table) table and the Activity Metrics Detail table (fact table)

 

Finance MBU is found in both the Business table (dimension table) table and the Activity Metrics Detail table (fact table)

 

Can you clarify what you mean?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors