cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

DAX related not work in measure

How to use related in measure?

 

 

sumX
VAR multiplier =
    IF (
        RELATED('units'[MAT_12]) <> BLANK ();
        RELATED('units'[MAT_12]);
        1
    )
RETURN
    DIVIDE(
        [AllSubNamePrice];
        [AllSubNameCount]
    )*multiplier

 

That code do not work

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: DAX related not work in measure

Hi @Analitika 

 

RELATED expects row context and there isn't one there.

Measures expect aggregation, try the below.

sumX = 
VAR multiplier =
    IF (
        SELECTEDVALUE('units'[MAT_12]) <> BLANK ();
        SELECTEDVALUE('units'[MAT_12]);
        1
    )
RETURN
    DIVIDE(
        [AllSubNamePrice];
        [AllSubNameCount]
    )*multiplier

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

1 REPLY 1
Highlighted
Super User IV
Super User IV

Re: DAX related not work in measure

Hi @Analitika 

 

RELATED expects row context and there isn't one there.

Measures expect aggregation, try the below.

sumX = 
VAR multiplier =
    IF (
        SELECTEDVALUE('units'[MAT_12]) <> BLANK ();
        SELECTEDVALUE('units'[MAT_12]);
        1
    )
RETURN
    DIVIDE(
        [AllSubNamePrice];
        [AllSubNameCount]
    )*multiplier

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors