cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Distinct Dax Explain

Hi ALL ,

 

Basically I would like to understand the behaviour of the below dax and what would be the best way to write the same for the scenario mentioned below.

 

I have a calculated column - 

TARGET = IF([Year]=2016,3.8,IF([Year]=2015,3.8,IF([Year]=2017,3.2,3.1)))
 
Now on top of it we have a measure - 
TARGET_Measure = IF(DISTINCT('KPI'[TARGET])=BLANK(),0,DISTINCT('KPI'[TARGET]))
 
This measure fails with error :-
Error Message:
MdxScript(Model) (31, 38) Calculation error in measure 'VETTING KPI'[TARGET_MRM_]: A table of multiple values was supplied where a single value was expected.

But it works correctly if i apply year filter
  
I want  to further use this measure in calculation of another measure =
DIVIDE([Target_measure] - [Obs Per Insp],[Target_measure],0))
 
1 ACCEPTED SOLUTION

Accepted Solutions
sturlaws Established Member
Established Member

Re: Distinct Dax Explain

Hi @Anonymous,

 

it's due to the code for the measure TARGET. If there is no filter context on year, [YEAR] will return all years available in that column, and the engine don't know what year to use. You would have to decide which value to use when there is no filter context for year.

 

One option is to return blank:

TARGET =
IF (
    HASONEVALUE ( [Year] ),
    SWITCH ( VALUES ( [year] ), 2016, 3.8, 2015, 3.8, 2017, 3, 2, 3.1 ),
    BLANK ()
)

 

best regards,

Sturla

2 REPLIES 2
sturlaws Established Member
Established Member

Re: Distinct Dax Explain

Hi @Anonymous,

 

it's due to the code for the measure TARGET. If there is no filter context on year, [YEAR] will return all years available in that column, and the engine don't know what year to use. You would have to decide which value to use when there is no filter context for year.

 

One option is to return blank:

TARGET =
IF (
    HASONEVALUE ( [Year] ),
    SWITCH ( VALUES ( [year] ), 2016, 3.8, 2015, 3.8, 2017, 3, 2, 3.1 ),
    BLANK ()
)

 

best regards,

Sturla

Highlighted
Anonymous
Not applicable

Re: Distinct Dax Explain

Thanks for the help @sturlaws

Helpful resources

Announcements
Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 340 members 3,235 guests
Please welcome our newest community members: