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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
carguello726
Frequent Visitor

Data Modeling Problems

Hi Power BI Pros,

I have a data model with 1 fact table and 2 lookup/dimension tables:

  1. Material Lookup
  2. Customer Lookup

I wish to view sales by customer and material. The pivot table works properly as shown below.

 

(Note - I am using Power Pivot to better illustrate my problem)
Current Results.PNG
Below is the data model.

Data Model.PNG
I have this DAX function (yields TRUE/FALSE) that is essentially a helper "column" for followup logical DAX functions. When I introduce this function into a pivot table or matrix, the results display what appears to be the FULL list of material items from my material lookup table. Recall that I only had 4 items for this particular customer prior to introducing this DAX function (see screenshot 1.
Actual Results.JPG


Here is the DAX function. It is quite long but it checks for 3 things and returns a TRUE/FALSE

 

  1. Whether the item is classified as "Material" (e.g. is LookupMaterial[Material Test] = 1?)
  2. Are sales greater than 0 in 2019 and 2018
  3. Is the change in average selling price (ASP) < 75%

SAME MATERIAL TEST=

 

VAR

      IsThisMaterial = IF(CALCULATE(MIN(LookupMaterial[Material Test]))=1,TRUE(),FALSE())

     

VAR

      SalesBothPeriod = AND([2019 Net Value II]>0, [2018 Net Value II]>0)

 

VAR

      ASPChange = IF(OR([2019 ASP]=0,[2018 ASP] = 0), 0, ABS(DIVIDE(MAX([2019 ASP],[2018 ASP]) , MIN([2019 ASP],[2018 ASP]))-1))

 

RETURN

 

IsThisMaterial && SalesBothPeriod && ASPChange <.75



Can someone please tell me how to get the desired results below? I wish to only display the list of material items that are applicable to the customer.
Desired Results.JPG
I initially had this as one giant fact table and it worked just fine. This issue started when I tried to optimize the data model by using dimension tables. 

Thank you in advance.

Chris

4 REPLIES 4
jdbuchanan71
Super User
Super User

Previously, when you used the material from the single big table your measure would return blank on the rows with no matches (the materials the customer did not buy), now it is able to evaluate a FALSE so it shows the line.  Try adding a check in the return like this.

SAME MATERIAL TEST =
VAR IsThisMaterial =
    IF (
        CALCULATE ( MIN ( LookupMaterial[Material Test] ) ) = 1,
        TRUE (),
        FALSE ()
    )
VAR SalesBothPeriod =
    AND ( [2019 Net Value II] > 0, [2018 Net Value II] > 0 )
VAR ASPChange =
    IF (
        OR ( [2019 ASP] = 0, [2018 ASP] = 0 ),
        0,
        ABS (
            DIVIDE ( MAX ( [2019 ASP], [2018 ASP] ), MIN ( [2019 ASP], [2018 ASP] ) ) - 1
        )
    )
RETURN
    IF (
        AND ( ISBLANK ( [2018 Sales] ), ISBLANK ( [2019 Sales] ) ),
        BLANK (),
        IsThisMaterial && SalesBothPeriod && ASPChange < .75
    )

I tried your solution but unfortunately it produced the same result. Any other suggestions?

@carguello726 Are you able to share your .pbix file?

VasTg
Memorable Member
Memorable Member

@carguello726  Please provide a mockup PBIX file to analyze.

 

One suggestion to test the DAX by using each variable in return function and check for expected results for each line or split a complex DAX to multiple measures, test them and combine when it works.

Connect on LinkedIn

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.