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
missmanou26
Frequent Visitor

NVL equivalent in DAX but in 2 different tables

Hello all,

I have an issue with a DAX function, I want to make equivalent to this:

IF(D_IMMEUBLE[IMM_OPE]=BLANK(),RELATED(D_IMMEUBLE[IMM_OPE]),D_SOCIETE[SOC_OPE_DEF]))
I have one to many relationship between D_SOCIETE and D_IMMEUBLE.
But when I run the DAX formula I have this message issue:
A single value for column 'IMM_OPE' in table 'D_IMMEUBLE' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
 How can I fix this problem please ?
Many thanks for your help.Capture.JPG
 
 

 

1 ACCEPTED SOLUTION

Hi @missmanou26 ,

As checked the model in your report file, there is no direct relationship between the table D_SOCIETE and D_IMMEUBLE. So it would get the error when using RELATED ( D_SOCIETE[SOC_OPE_DEF] ) in the formula.... I updated your sample pbix file(see the attachment), please check if that is what you want. Please update the formula of calculated column [Operation_GL] as below:

Operation_GL = 
VAR _sksoc =
    CALCULATE (
        MAX ( 'TR_TIERS'[SK_SOC] ),
        FILTER ( 'TR_TIERS', 'TR_TIERS'[SK_IMM] = 'D_IMMEUBLE'[SK_IMM] )
    )
VAR _sod =
    CALCULATE (
        MAX ( D_SOCIETE[SOC_OPE_DEF] ),
        FILTER ( 'D_SOCIETE', 'D_SOCIETE'[SK_SOC] = _sksoc )
    )
RETURN
    IF ( ISBLANK ( D_IMMEUBLE[IMM_OPE] ), _sod, D_IMMEUBLE[IMM_OPE] )

yingyinr_0-1675648808863.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
missmanou26
Frequent Visitor

Sorry, I've just granted the permissions.

Thank you !

Hi @missmanou26 ,

As checked the model in your report file, there is no direct relationship between the table D_SOCIETE and D_IMMEUBLE. So it would get the error when using RELATED ( D_SOCIETE[SOC_OPE_DEF] ) in the formula.... I updated your sample pbix file(see the attachment), please check if that is what you want. Please update the formula of calculated column [Operation_GL] as below:

Operation_GL = 
VAR _sksoc =
    CALCULATE (
        MAX ( 'TR_TIERS'[SK_SOC] ),
        FILTER ( 'TR_TIERS', 'TR_TIERS'[SK_IMM] = 'D_IMMEUBLE'[SK_IMM] )
    )
VAR _sod =
    CALCULATE (
        MAX ( D_SOCIETE[SOC_OPE_DEF] ),
        FILTER ( 'D_SOCIETE', 'D_SOCIETE'[SK_SOC] = _sksoc )
    )
RETURN
    IF ( ISBLANK ( D_IMMEUBLE[IMM_OPE] ), _sod, D_IMMEUBLE[IMM_OPE] )

yingyinr_0-1675648808863.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes it worked ! Thank you very much for your help

v-yiruan-msft
Community Support
Community Support

Hi @missmanou26 ,

It seems that what you are trying to create is a measure, that's why you got that error message. You can get more details in the following blog...

DAX error messages in Power BI

You can create a calculated column as below in the table 'D_IMMEUBLEto replace the current measure:

Column =
IF (
    D_IMMEUBLE[IMM_OPE] = BLANK (),
    RELATED ( D_SOCIETE[SOC_OPE_DEF] ),
    D_IMMEUBLE[IMM_OPE]
)

If the above one can't help you, could you please provide some raw data in the table 'D_IMMEUBLE' and 'D_SOCIETE' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-yiruan-msft 

I already tried to create a calculated column but I get also an error. Here's a simplified pbix file.

https://drive.google.com/file/d/1zMRU1VXHPyMolfVGeqUQxQNevrmGHknO/view?usp=share_link

Thanks a lot for your help.

Hi @missmanou26 ,

It seems that I don't have the proper access to your shared file, could you please grant me the sufficient permission to it? Thank you.

How to upload PBI in Community

yingyinr_0-1675415817955.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.