Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
5 years ago
Solved

Dax Formula Optimization Help

Hello everyone I need help to see if it is possible to optimize the following DAX formula: The idea is that when the user changes the what-if parameters that he has on his screen, the fo...
  • parry2k's avatar
    5 years ago

    Syndicate_Admin try this, first not sure why you are storing the result  in a table, and seems like you have filter on CustomerID from the same table, without knowing everything try this:

     

    TotalPositive =
    var __value = 
    SWITCH ( [AnalysisId],
    1, [Valor Ecoli PARAM],
    2, [Valor Ecoli 0157:H7 PARAM],
    3, [Valor Enterobacteriaceae PARAM],
    4, [Valor Fecal Coliform PARAM],
    7, [Valor Listeria PARAM],
    8, [Valor Mold],
    9, [Valor Others PARAM],
    10, [Valor Pseudomonas PARAM],
    11, [Valor Salmonella PARAM],
    12, [Valor Shigella PARAM],
    13, [Valor Staphylococcus aureus PARAM],
    14, [Valor STEC PARAM],
    15, [Valor STEC/EC O157:H7 PARAM],
    16, [Valor Total Coliform PARAM],
    17, [Valor TPC PARAM],1
    18, [Valor Yeast]
    ,0)
    var TPositive =
    CALCULATE(DISTINCTCOUNT(MicroHeader[AuthLabID]), MicroHeader[sign] <> "<"
    FILTER ( MicroHeader, [Total Amount] > __value 
    ) + 0
    RETURN
    Tpositive

     

    there might be a syntax error when I typed the code, so fix the code if run into any syntax error.

     

    Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.