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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Calculated column based on lookup table returns empty

I'm trying to calculate for every contract in a dataset with contracts whether or not a specific budget applies or not. This budget I need to detract from my overall figure, so I need to have it on a contract to contract basis.

 

I have queried a simple lookup table where I have all the relevant filter columns (product, model, duration, ...) and how high the specific budget is for these conditions. I want to calculate a column with for each contract the applied budget. I'll enclose my current DAX lines for calculating this column, and it does not give me syntax errors, but the resulting column is completely empty.

 

My main table is 'Retail+Fleet' and 'Special actions' is the small lookup table with the conditions and the [Budget action] column with the size of the specific budget. I've also included a simplified version of the two tables, where the green column indicates what I expected the resulting column to look like, but that at the moment is completely empty (not even showing null or 0). Does anyone have an idea where I'm making a mistake?

 

SpecialAction = 
    /* Use if lookup doesn't bring anything back - this is for easiness just set to 0 */
        VAR DefaultAction = 0

    /* Product Class (to filter on PL) */
        VAR ProductPL = 'Retail+Fleet'[Product Class]
    
    /* New Car */
        VAR NewCar = 'Retail+Fleet'[New/Used car]

    /* Duration */
        VAR Duration = 'Retail+Fleet'[Contract duration]

    /* Calculation Date */
        VAR CalculationDate = 'Retail+Fleet'[Calculation date]
        
    /* CMIS Brand */
        VAR CMISBrand = 'Retail+Fleet'[CMIS Brand]
                
    /* Model */
        VAR CarModel = 'Retail+Fleet'[Model]

    /** Filter all contracts to see whether they fall within the specific conditions, and check whether the creation date falls within the to and from date range.
        The BLANK() value ensures that for the lines where the Car Model or the Duration is not filled in, the filter option is not stopped.
    **/

RETURN
    CALCULATE(FIRSTNONBLANK('Special actions'[Budget action],1),
        FILTER(
                'Special actions',
                'Special actions'[Product Class] = ProductPL
                && CalculationDate >= 'Special actions'[Date From]
                && CalculationDate <= 'Special actions'[Date To]
                && 'Special actions'[VN - VO] = NewCar
                && ('Special actions'[Duration] <= Duration || 'Special actions'[Duration] = BLANK())
                && 'Special actions'[CMIS Brand] = CMISBrand
                && ('Special actions'[Model] = CarModel || 'Special actions'[Model] = BLANK())
            ))

 

Lookup Table ('Special actions')

Product ClassCMIS BrandModelDurationDate FromDate ToVN - VOBudget action

PL

Brand 1 241/1/2431/1/24VN800
PLBrand 1 361/1/2431/1/24VN1000
PLBrand 1 481/1/2431/1/24VN1000
PLBrand 1Model 1481/1/2431/1/24VN1500
PLBrand 2Model 2481/1/2431/1/24VN600
PLBrand 3Model 3481/1/2431/1/24VN600

 

Main Table ('Retail+Fleet')

Product ClassCMIS BrandModelContract DurationCalculation date...New/Used carSpecialAction

AC

Brand 1Model 636

20/12/23

...VN 
CCBrand 1Model 402430/12/23...VN 
OLBrand 1Model 1603/1/24...VN 
PLBrand 2Model 2485/1/24...VN600
PLBrand 3Model 44812/1/24...VN 
PLBrand 1Model 26019/1/24...VO 
PLBrand 1Model 12430/1/24...VN1500
PLBrand 1Model 3362/2/24...VN 
PLBrand 2Model 33018/2/24...VO 
PLBrand 3Model 2721/3/24...VN 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you for reproducing my problem in any case! This helped enormously since I knew it was not a problem of calculation, rather a data-problem on my end. I found the problem in the end, where it was one of the columns not exactly matching the comparable column in the other table. So my code did not find any matches and therefore returned empty. Thank you!

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Cannot reproduce. Did you accidentally try to create a measure?

 

See attached.

 

 

Anonymous
Not applicable

Thank you for reproducing my problem in any case! This helped enormously since I knew it was not a problem of calculation, rather a data-problem on my end. I found the problem in the end, where it was one of the columns not exactly matching the comparable column in the other table. So my code did not find any matches and therefore returned empty. Thank you!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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