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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sravani9920
Frequent Visitor

DAX needed

Hello Guys,
I have provided the sample data for you, Here status column is the Result column for my requirement, student should be passed in all the tests then only status should be pass, If any student fail in one test also status will be fail,
I need to present the data in PIE chart like number of test failed and passed.
Please any one help me on this,
Thank you in advance.

number 

Nametest Pass/failstatus
sravanitest1Passfail
sravanitest2Passfail
sravanitest3failfail
srinutest1Passpass
srinutest2Passpass
siritest1Passpass
siritest2Passpass
siritest3Passpass
mokshutest1failfail
mokshutest2passfail
mokshutest3passfail
mokshutest4passfail
1 ACCEPTED SOLUTION

Hi @sravani9920 ,

You need to add the class on your solution:
Power Query:

  • Class must be added to the Group By and Merged queries steps:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKi5KLEvMy1TSUSpJLS4xBNIBicXFQMpQKVYHXdoIv7QxkE5LzMxBks7MK8U02hhD0ghDMrMIt5sQcpgOQsgZo8vl5mcXZyA7B8WtKLIgcwtw6jXGK2uCLosziI3wBzFQOhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"test " = _t, #"Pass/fail" = _t, Class = _t]),
    #"Uppercased Text" = Table.TransformColumns(Source,{{"Pass/fail", Text.Upper, type text}}),
    #"Grouped Rows" = Table.Group(#"Uppercased Text", {"Name", "Class"}, {{"Status", each List.Min([#"Pass/fail"]), type text}}),
    #"Merged Queries" = Table.NestedJoin(Source, {"Name","Class"}, #"Grouped Rows", {"Name", "Class"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Status"}, {"Status"})
in
    #"Expanded Grouped Rows"

MFelix_0-1713887772401.png

Calculated column:

Status DAX = 
VAR temptable = FILTER(
		SUMMARIZE(
			ALL(Grades),
			Grades[Name],
            Grades[Class],
			Grades[Pass/fail]
		),
		Grades[Name] = EARLIER(Grades[Name]) &&
        Grades[Class] = EARLIER(Grades[Class])
	)
	RETURN
		MINX(
			temptable,
			Grades[Pass/fail]
		)

MFelix_1-1713887917255.png

Dax measure:

Status per student = VAR temptable = SUMMARIZE(
			Grades,
			Grades[Name],
            Grades[Class],
			"@status", MIN(Grades[Pass/fail])
		)
		RETURN
			COUNTROWS(FILTER(
				temptable,
				[@status] IN VALUES('Status'[Status])
			))

MFelix_4-1713888017178.png

 

File attach


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

5 REPLIES 5
MFelix
Super User
Super User

Hi @sravani9920 ,

 

Believe you can use one of this options:
Powern Query:
Making use of the current query

  • Uppercase the fail/pass (to avoid errors on next steps)

MFelix_0-1713435485620.png

 

  • Group by Name and with MIN Pass/Fail Column

MFelix_1-1713435503839.png

 

  • Merge the query with itself

MFelix_2-1713435523000.png

 

  • Change on the Merge Step the first table by the last step befor the uppercase (in my example was the source step)

MFelix_4-1713435542001.pngMFelix_5-1713435544196.png

  • Expand the column status

MFelix_6-1713435556699.png

 

Column using DAX:
Create the following column:

Status DAX = 
VAR temptable = FILTER(
		SUMMARIZE(
			ALL(Grades),
			Grades[Name],
			Grades[Pass/fail]
		),
		Grades[Name] = EARLIER(Grades[Name])
	)
	RETURN
		MINX(
			temptable,
			Grades[Pass/fail]
		)

MFelix_7-1713436342472.png

 

Use a disconnected table and measure:

  • Create a table with the Pass/Fail values
  • Add the following measure:
Status per student = VAR temptable = SUMMARIZE(
			Grades,
			Grades[Name],
			"@status", MIN(Grades[Pass/fail])
		)
		RETURN
			COUNTROWS(FILTER(
				temptable,
				[@status] IN VALUES('Status'[Status])
			))

MFelix_8-1713436729612.png

Pbix file attach

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helli MFelix,

It worked well for me but need to extend the DAX calcultaed formula as sravani student in class 2 then the status should be Pass for class 2 as all the tests passed in class2 and same person is failed in class 1 so status for should be failed,
Please help me out by extending the Dax calcultaed formula,

Thank you 🙂

sravani9920_0-1713850409974.png

 

Hi @sravani9920 ,

You need to add the class on your solution:
Power Query:

  • Class must be added to the Group By and Merged queries steps:
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKi5KLEvMy1TSUSpJLS4xBNIBicXFQMpQKVYHXdoIv7QxkE5LzMxBks7MK8U02hhD0ghDMrMIt5sQcpgOQsgZo8vl5mcXZyA7B8WtKLIgcwtw6jXGK2uCLosziI3wBzFQOhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"test " = _t, #"Pass/fail" = _t, Class = _t]),
    #"Uppercased Text" = Table.TransformColumns(Source,{{"Pass/fail", Text.Upper, type text}}),
    #"Grouped Rows" = Table.Group(#"Uppercased Text", {"Name", "Class"}, {{"Status", each List.Min([#"Pass/fail"]), type text}}),
    #"Merged Queries" = Table.NestedJoin(Source, {"Name","Class"}, #"Grouped Rows", {"Name", "Class"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Status"}, {"Status"})
in
    #"Expanded Grouped Rows"

MFelix_0-1713887772401.png

Calculated column:

Status DAX = 
VAR temptable = FILTER(
		SUMMARIZE(
			ALL(Grades),
			Grades[Name],
            Grades[Class],
			Grades[Pass/fail]
		),
		Grades[Name] = EARLIER(Grades[Name]) &&
        Grades[Class] = EARLIER(Grades[Class])
	)
	RETURN
		MINX(
			temptable,
			Grades[Pass/fail]
		)

MFelix_1-1713887917255.png

Dax measure:

Status per student = VAR temptable = SUMMARIZE(
			Grades,
			Grades[Name],
            Grades[Class],
			"@status", MIN(Grades[Pass/fail])
		)
		RETURN
			COUNTROWS(FILTER(
				temptable,
				[@status] IN VALUES('Status'[Status])
			))

MFelix_4-1713888017178.png

 

File attach


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank You so much Dear, It works🙂

PhilipTreacy
Super User
Super User

Hi @sravani9920 

 

Download PBIX file with the examples below

 

This measure will give you the Status column as shown  in your example

 

Status = IF(CALCULATE(COUNTROWS('DataTable'), FILTER(ALL('DataTable'), 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name]) && 'DataTable'[Pass/fail] = "fail")), "Fail", "Pass")

 

 

passfail.png

 

These measures will give you the number of tests passed and failed by each person

 

 

Tests Passed = CALCULATE(COUNTROWS('DataTable'), FILTER(('DataTable'), 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name]) && 'DataTable'[Pass/fail] = "pass"))

 

 

 

Tests Failed = CALCULATE(COUNTROWS('DataTable'), FILTER(('DataTable'), 'DataTable'[Name] = SELECTEDVALUE('DataTable'[Name]) && 'DataTable'[Pass/fail] = "fail"))

 

 

I don't think a pie chart is the best visual for this data, how exactly do you expect it to look?  Segments are coloured by the candidate, so both pased and failed tests are the same colour for each person.  

passfailpie.png

 

A column chart would be better

passfailcol.png

 

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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