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
Anonymous
Not applicable

multiple results- the query fails

I am trying to link between header table and the fact table in order to get correct values:

Formules =
VAR Top1 = SELECTEDVALUE ( EnteteRapportAgentClient[Top] )
VAR Middle = SELECTEDVALUE ( EnteteRapportAgentClient[Middle] )
VAR BottomIndex = SELECTEDVALUE ( EnteteRapportAgentClient[Index3] )VAR a = SELECTEDVALUE(Dim_DateFicheAgent[ID_DateFicheAgent])
VAR b =SELECTEDVALUE('Seniority banking'[banking seniority])VAR Bottom = SELECTEDVALUE ( EnteteRapportAgentClient[Bottom] )
RETURN
VAR Val =
    SWITCH (
        TRUE ();
        Top1 = "Nombre de leads"; [Lead]+ 0;Top1 = "Affaires nouvelles" && BottomIndex <> 0;CALCULATE(COUNTROWS(FILTER(Fact_AN;

     (Fact_AN[banking seniority]<=b && NOT ISBLANK (Fact_AN[banking seniority]) &&Fact_AN[Code_Produit ]=LOOKUPVALUE (
    Dim_Produit[Code_Produit ] ;
    Dim_Produit[Dim5Rapport];Middle;
    Dim_Produit[Dim6Rapport];Bottom
))));
         DATESBETWEEN (
        Dim_DateFicheAgent[ID_DateFicheAgent];
        NEXTDAY ( SAMEPERIODLASTYEAR (LASTDATE ( Dim_DateFicheAgent[ID_DateFicheAgent] ) ));
        LASTDATE ( Dim_DateFicheAgent[ID_DateFicheAgent] )

));
        Middle="Affaires nouvelles"; [AN]+0;
        Middle = "Total AN";[AN]+ 0;
        Middle = "Taux Transfo"; DIVIDE([AN];[Lead])
    )
VAR ValF=
  
     IF(   Middle = "Taux Transfo";
        FORMAT ( Val; "0.0%" );
        FORMAT ( Val; "0" ))
VAR Val2=
     IF (ValF="0";"";ValF
    )RETURN Val2
 
I get an error
 
Capture.PNG
 
2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@Anonymous 
It is difficult to test with this overly long dax, try separate the measure into multiple measure.

The error is most likely because of you are having 2 "Return" in the formula, but you only expect to have 1 return value in any measure or column.

 

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

sanimesa
Post Prodigy
Post Prodigy

@Anonymous  It looks like in order for your measure to work, you will need to select a few values. Please see the picture, I added a couple of slicers and at least now the error is gone.

PBI Help selection issue.PNG

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.