Forum Discussion

igorpereiradaco's avatar
igorpereiradaco
Frequent Visitor
2 years ago
Solved

help to solve logical problem

I would like to create a condition in DAX that allows me to display the status of the item based on the scenario associated with it and the status of the tests associated with that scenario.

The proposal is that, if the tests linked to a given scenario are approved, then the scenario must be marked as "ok".

Additionally, if all scenarios linked to an item are marked as "ok", then the item is also marked as "ok".

 

 

10 Replies

  • do the following:

    Create a Calculated Column for Scenario Status

    Scenario Status = VAR ScenarioID = 'YourTableName'[Scenario] RETURN IF ( COUNTROWS ( FILTER ( 'YourTableName', [Cenario] = ScenarioID && [Teste Status] <> "Approved" ) ) = 0, "Ok", "Not Ok" )

     

     Create a Calculated Column for Item Status

    Item Status = VAR ItemID = 'YourTableName'[Item ID] RETURN IF ( COUNTROWS ( FILTER ( 'YourTableName', [Item ID] = ItemID && [Scenario Status] <> "Ok" ) ) = 0, "Ok", "Not Ok" )

     

    If this helped, Follow this blog for more insightful information about data analytics
    https://analyticpulse.blogspot.com/
    Please Subscribe AnalyticPulse on YouTube for future updates:
    https://www.youtube.com/@AnalyticPulse
    Please subscribe CogniJourney On Youtube For Daily fun facts:
    https://www.youtube.com/@CogniJourney

    • igorpereiradaco's avatar
      igorpereiradaco
      Frequent Visitor

      Good morning. Thanks for the feedback. I couldn't do it that way.

  • talespin's avatar
    talespin
    Solution Sage

    hi igorpereiradaco 

     

    Please try these measures

     

    ScenarioStatus =
    VAR _MinVal = CALCULATE( MINX(LogicalProblem, IF(LogicalProblem[Column1] = "ok", 1 , 0) ), REMOVEFILTERS(), VALUES(LogicalProblem[Scenario]) )
    RETURN IF(_MinVal = 1, "ok", "Not ok")
     
    ItemStatus =
    VAR _MinVal = CALCULATE( MINX(LogicalProblem, IF(LogicalProblem[Column1] = "ok", 1 , 0) ), REMOVEFILTERS(), VALUES(LogicalProblem[ItemID]) )
    RETURN IF(_MinVal = 1, "ok", "Not ok")
     

     

    • igorpereiradaco's avatar
      igorpereiradaco
      Frequent Visitor

      Good morning. Thanks for the feedback. The solution is this. Can you send me this pbix file?

    • igorpereiradaco's avatar
      igorpereiradaco
      Frequent Visitor

      Friend, good afternoon.

       

      What would it look like if I wanted to assign more status to the scenarios and items, as below:

       

      if all tests are "Prevented user test" then scenario of the item "Prevented user test"

      if all tests are "Not tested" then item scenario 'Not tested"

      if all tests are "Prevented" then item scenario "Not tested"

      if all tests are "In user testing" then scenario of the item "In user testing"

      if all tests are "Approved" then scenario of the item "Approved"

       

       

      if all scenarios are "Prevented user test" then test the item "Prevented user test"

      if all scenarios are "Not tested" then test the item 'Not tested"

      if all scenarios are "Prevented" then test the item "Not tested"

      if all scenarios are "Under test" then test the item "Under test"

      if all scenarios are "Approved" then test the item "Approved"

      • talespin's avatar
        talespin
        Solution Sage

         igorpereiradaco 

         

        This should do it. I noticed one thing, you have 

        if all tests are "In user testing" then scenario of the item "In user testing"

        if all scenarios are "Under test" then test the item "Under test"

         

        ScenarioStatus =
        VAR _MinVal = CALCULATE(
                                MIN(LogicalProblem[Column1]),
                                REMOVEFILTERS(),
                                VALUES(LogicalProblem[Scenario])
                            )
        VAR _MaxVal = CALCULATE(
                                MAX(LogicalProblem[Column1]),
                                REMOVEFILTERS(),
                                VALUES(LogicalProblem[Scenario])
                            )                  
        RETURN IF(
                    _MinVal = _MaxVal,
                    IF(_MaxVal = "Prevented", "Not tested", _MaxVal),
                    "NA"
                )
        -----------------------------------------------------------------------------
        ItemStatus =
        VAR _MinVal = CALCULATE(
                                MIN(LogicalProblem[Column1]),
                                REMOVEFILTERS(),
                                VALUES(LogicalProblem[ItemID])
                            )
        VAR _MaxVal = CALCULATE(
                                MAX(LogicalProblem[Column1]),
                                REMOVEFILTERS(),
                                VALUES(LogicalProblem[ItemID])
                            )                  
        RETURN IF(
                    _MinVal = _MaxVal,
                    IF(_MaxVal = "Prevented", "Not tested", _MaxVal),
                    "NA"
                )
         
        File Link: