Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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
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:
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.
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 @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!!
Proud to be a Super User! | |
Here is data in WorkUnit Table and PF is measure created on frontend based on logic.
Work Units | Class Code | PF |
2P006 | 110 | Pass |
2A010 | 114 | Fail |
2A011 | 105 | Fail |
2J012 | 109 | Pass |
2A013 | 105 | Fail |
2W014 | 105 | Pass |
2M015 | 110 | Fail |
2A016 | 105 | Fail |
2Q017 | 105 | Fail |
2A018 | 103 | Pass |
2F019 | 105 | Fail |
2A021 | 101 | Pass |
2A022 | 105 | Pass |
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:
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:
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:
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:
failorpass =
IF ( 'Score'[Score] < 60, "fail", "pass" )
Then create a Measure to calculate the value of pass or fail:
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:
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.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.