Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Create Visual on frontend measures

Hi,

 

I have created one  measure on PowerBI Desktop having only pass and fail values based on logic, now we want to create bar type chart on count of these pass and fail values. Is it possible to do so ? That measure will have only pass or fail values.

 

Thanks,

Bhimashankar

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, rajendraongole1 

    I am in favor of your approach. 

    And I would like to share some additional solutions below. 

     

    Hi, Anonymous 

    I am glad to help you.   

     

    According to your description, you want to create bar type chart on count of these pass and fail values? 

     

    If I understand you correctly, then you can refer to my solution.  

     

    Since you didn't give specific test data, I created a simple dataset based on your description and tested a simple example, so I hope this helps. 

    Dataset: 

     

     

    Create a Measure calculation Pass or Fail: 

     

     

    PassOrFail = 
    SWITCH (
        TRUE (),
        ISERROR ( SUM ( 'Score'[Score] ) ), "Error",
        SUM ( 'Score'[Score] ) >= 60, "Pass",
        SUM ( 'Score'[Score] ) < 60, "Fail"
    )
    

     

     

    Based on this logical Measure, create a table for counting the number of passes or failures via New Table: 

     

     

    PassFailCountTable = 
    SUMMARIZE (
        ADDCOLUMNS ( 'Score', "PassOrFail", [PassOrFail] ),
        [PassOrFail],
        "Count", COUNTROWS ( 'Score' )
    )
    

     

     

    Apply the newly created table to the bar chart: 

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for your detailed solution. I tried on PowerBI Desktop, data from excel it is working fine. Unfortunately I don't have access to create table on frontend is there any other way to do it ?

  • Hi Anonymous - Can please share some sample data for more analysis, it helps to understand

     

    as per my understanding , you can create a measure that uses a SWITCH statement to dynamically count Pass and Fail based on a selected value

     

    DynamicCount =
    SWITCH (
    SELECTEDVALUE('PassFailTable'[PassFail]),
    "Pass", CALCULATE(COUNTROWS('YourTable'), 'YourTable'[PassFailMeasure] = "Pass"),
    "Fail", CALCULATE(COUNTROWS('YourTable'), 'YourTable'[PassFailMeasure] = "Fail"),
    BLANK()
    )

     

    Hope it works and helps

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!

    • Anonymous's avatar
      Anonymous
      Not applicable

      Here is data in WorkUnit Table and PF is measure created on frontend based on logic.

      Work UnitsClass CodePF
      2P006110Pass
      2A010114Fail
      2A011105Fail
      2J012109Pass
      2A013105Fail
      2W014105Pass
      2M015110Fail
      2A016105Fail
      2Q017105Fail
      2A018103Pass
      2F019105Fail
      2A021101Pass
      2A022105Pass

       

      From your suggested answer I don't any 'PassFailTable' ?
      Please refer data above and table name, as suggested by Anonymous It worked but I don't have access to create new table on frontend.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi, Anonymous 

        New Table is done in Power BI Desktop as follows:

         

         

        I don't know the calculation logic of your Measure CodePF.
        In my example, my Measure PassOrFail is your Measure CodePF, you just need to change the corresponding parameter in the DAX formula of New Table:

        PassFailCountTable = 
        SUMMARIZE (
            ADDCOLUMNS ( 'WorkUnit', "PassOrFail", [CodePF] ),
            [CodePF],
            "Count", COUNTROWS ( 'WorkUnit' )
        )

         


        I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
        Best Regards,
        Fen Ling,
        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.