Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Support with DAX Function NOT Working

Hi Community,

 

Need your! Can anyone tell me why when I do not have a selection on the two VAR below 'aaa' and 'bbb', my chart is blank? 

Can I get anyone's support to adjust the function in order to have the bit "VAR SUM_ORC = CALCULATE(SUM(t_Incorridas_SGC[Incorridas_Totais_Recurso]))" working, even if there are no selections at all? 

 

Thank you so much! 

 

 

Effort Hrs. =
VAR bbb = CALCULATE(SELECTEDVALUE(t_Detalhe_Processos_Fases_Tarefas[Ref_GIP]))
VAR aaa = CALCULATE(MAX(t_Detalhe_Processos_Fases_Tarefas[Data_Info]);
FILTER(t_Detalhe_Processos_Fases_Tarefas; t_Detalhe_Processos_Fases_Tarefas[Ref_GIP] = bbb)
)
VAR SUM_ORC = CALCULATE(SUM(t_Incorridas_SGC[Incorridas_Totais_Recurso]);
FILTER(t_Detalhe_Processos_Fases_Tarefas;t_Detalhe_Processos_Fases_Tarefas[Ref_GIP] = bbb);
FILTER(t_Detalhe_Processos_Fases_Tarefas;t_Detalhe_Processos_Fases_Tarefas[Data_Info] = aaa))
RETURN

IF(SELECTEDVALUE(t_Detalhe_Processos_Fases_Tarefas[Data_Info]) = aaa
|| SELECTEDVALUE(t_Detalhe_Processos_Fases_Tarefas[Ref_GIP]) = bbb;
CALCULATE(SUM_ORC); CALCULATE(SUM_ORC))
  • Anonymous  Guess, you are looking for a Measure something like this... Show the relevant sum while there is a selection and if there is no selection then show total sum.

     

    Test232 = 
    VAR _SelectedSUM = CALCULATE(SUM(emp[sal]),FILTER(emp,emp[deptno] = SELECTEDVALUE(emp[deptno])))
    VAR _TotalSUM = SUM(emp[sal])
    RETURN IF(ISBLANK(_SelectedSUM),_TotalSUM,_SelectedSUM)

8 Replies

  •  so theThe first VAR seems to be incorrect
    VAR bbb = CALCULATE(SELECTEDVALUE(t_Detalhe_Processos_Fases_Tarefas[Ref_GIP]))

    It will always return blank if nothing is selected in t_Detalhe_Processos_Fases_Tarefas[Ref_GIP] and so the filter will return a blank set of rows, resulting in a blank chart

    I think you need to change the logic of VAR bbb

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you! 

       

  • PattemManohar's avatar
    PattemManohar
    Community Champion

    Anonymous  Guess, you are looking for a Measure something like this... Show the relevant sum while there is a selection and if there is no selection then show total sum.

     

    Test232 = 
    VAR _SelectedSUM = CALCULATE(SUM(emp[sal]),FILTER(emp,emp[deptno] = SELECTEDVALUE(emp[deptno])))
    VAR _TotalSUM = SUM(emp[sal])
    RETURN IF(ISBLANK(_SelectedSUM),_TotalSUM,_SelectedSUM)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Smooth! 

      Thanks a lot for your help. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi there, 

       

      Actually I found a small issue with the behaviour that it turned out. 

      With your logic applied, I was able to retrieve data even if no selections were made, however, when making a selection by month, it will not give values for that particular month, instead it retrieves the sum of it. 

       

      TEST = 

      VAR _SelectedSUM = CALCULATE(SUM(t_Incorridas_SGC[Incorridas_Totais_Recurso]);
      FILTER(t_Detalhe_Processos_Fases_Tarefas;t_Detalhe_Processos_Fases_Tarefas[Data_Info] = SELECTEDVALUE(t_Detalhe_Processos_Fases_Tarefas[Data_Info]));FILTER(t_Detalhe_Processos_Fases_Tarefas; t_Detalhe_Processos_Fases_Tarefas[Ref_GIP] = SELECTEDVALUE(t_Detalhe_Processos_Fases_Tarefas[Ref_GIP]))
      )

      VAR _TotalSUM = SUM(t_Incorridas_SGC[Incorridas_Totais_Recurso])

      RETURN IF(ISBLANK(_SelectedSUM);_TotalSUM;_SelectedSUM)