Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Bhimashankar_Dc
Frequent Visitor

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 7
v-fenling-msft
Community Support
Community Support

Hi, @rajendraongole1 

I am in favor of your approach. 

And I would like to share some additional solutions below. 

 

Hi, @Bhimashankar_Dc 

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: 

vfenlingmsft_0-1722230067424.png

 

 

Create a Measure calculation Pass or Fail: 

vfenlingmsft_1-1722230067425.png

 

 

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: 

vfenlingmsft_2-1722230083389.png

 

 

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

 

 

Apply the newly created table to the bar chart: 

vfenlingmsft_3-1722230083390.png

 

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.

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 ?

rajendraongole1
Super User
Super User

Hi @Bhimashankar_Dc - 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!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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 @v-fenling-msft It worked but I don't have access to create new table on frontend.

Hi, @Bhimashankar_Dc 

New Table is done in Power BI Desktop as follows:

vfenlingmsft_2-1722415257968.png

 

 

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.

Thanks for your solution, but I don't have the access to create new table in Power BI. Can we do it by any other way without using new table ?

Hi, @Bhimashankar_Dc 

Why can't you New Table, and what type of data source are you connecting to? 

 

If it says that you can't New Table, but you have to use a Measure that you created earlier, then unfortunately you can't use a bar chart to show the values of pass or fail. You can use Table visual or Matrix visual, etc. because Measure cannot be placed on the X axis. 

 

Since I have no way of knowing the computational logic behind your Measure, I'm still testing using the example I mentioned to you earlier.

 

For details you can refer to a new Measure I created instead of using New Table to calculate the pass or fail values: 

vfenlingmsft_0-1722821907792.png

 

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

(This Measure PassOrFail is equivalent to the Measure you use to calculate pass or fail logic) 

 

Showing the value of pass or fail: 

vfenlingmsft_1-1722821907793.png

 

 

M_1 = 
VAR _value = [PassOrFail]
RETURN
    CALCULATE (
        COUNTAX ( 'Score', [PassOrFail] ),
        FILTER ( ALL ( Score ), 'Score'[PassOrFail] = _value )
    )

 

Or can you modify the Measure you created to calculate columns, the X-axis can only place columns that exist in the table. If you can consider using calculated columns, you can refer to another option: 

First create a calculated column to calculate pass or fail: 

 

vfenlingmsft_2-1722821928576.png

 

failorpass = 
IF ( 'Score'[Score] < 60, "fail", "pass" )

 

Then create a Measure to calculate the value of pass or fail: 

vfenlingmsft_3-1722821928577.png

 

M_2 = 
VAR _value =
    MAX ( 'Score'[failorpass] )
RETURN
    CALCULATE (
        COUNT ( 'Score'[failorpass] ),
        FILTER ( ALL ( Score ), 'Score'[PassOrFail] = _value )
    )

 

This is the result shown using a bar graph: 

  

vfenlingmsft_4-1722821943069.png

 

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.

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors