cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TejeshGour Frequent Visitor
Frequent Visitor

Need help in DAX

Request for help:
I have two columns 'type' and 'VALUES' (in screenshot) in table and another table is facttable that contains detail so that i am trying to show similer data in Calculated Column1 which will show measure only.
I have written below expresssion but I am not getting data even not getting any error. Please have a look on return condition.

Calculated Column1:= var StudentCount1 = CALCULATE ( DISTINCTCOUNT(FactGrades[DimStudentsWid]), FILTER ( VALUES( FactGrades[PercentGradeReceived]) , COUNTROWS ( FILTER ( 'DimReportingConfig', FactGrades[PercentGradeReceived] >= 'DimReportingConfig'[MinValue] && FactGrades[PercentGradeReceived] < 'DimReportingConfig'[MaxValue]&&NOT(ISBLANK(FactGrades[PercentGradeReceived])) ) ) > 0 ) ) RETURN IF ( HASONEVALUE(SelectiomTable[Type]), SWITCH ( VALUES( SelectiomTable[Type] ), "SchoolYear", CALCULATE ( StudentCount1, TREATAS ( VALUES( SelectiomTable[VALUES] ),SectionEnrollment[SchoolYear] ) ), "GradeLevel", CALCULATE ( StudentCount1, TREATAS ( VALUES( SelectiomTable[VALUES] ), SectionEnrollment[GradeLevel]) ) ),0 )DataSample.PNG

10 REPLIES 10
Moderator v-qiuyu-msft
Moderator

Re: Need help in DAX

Hi @TejeshGour

 

Please provide some sample data of facttable, and clarify the desired output based on the data in screenshot and facttable sample data. 

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
TejeshGour Frequent Visitor
Frequent Visitor

Re: Need help in DAX

FactTable

I am trying to create dynamic category using slicer component.
Below is expression to created table in SSAS TOM MODEL:
var Race= CROSSJOIN(ROW("Type","Race"), VALUES(DimStudents[RaceName]))
var Gender= CROSSJOIN(ROW("Type","Gender"), VALUES(DimStudents[GenderName]))
var Hispanic = CROSSJOIN(ROW("Type","Hispanic"), VALUES(DimStudents[HispanicName]))
var SchoolYear= CROSSJOIN(ROW("Type","SchoolYear"), VALUES(SectionEnrollment[LatestSchoolYear]))
var SchoolName= CROSSJOIN(ROW("Type","SchoolName"), VALUES(DimSchool[SchoolName]))
return UNION(Race,Gender, Hispanic,SchoolYear,SchoolName)

TejeshGour Frequent Visitor
Frequent Visitor

Re: Need help in DAX

ReqPic.png
SchoolYear will be fix category and remaining will be based on selection

Moderator v-qiuyu-msft
Moderator

Re: Need help in DAX

Hi @TejeshGour

 

The FactTable link is not accessible. Please double check it. 

 

For your screenshot, it looks like there are four legends (Gender, Race, SchoolYear, SchoolName) display in the chart, you would like to keep the SchoolYear displaying regardless any filter will filter out SchoolYear, right? I'm afraid this is not supported currently. 

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Tejesh_Gour Regular Visitor
Regular Visitor

Re: Need help in DAX

https://drive.google.com/file/d/1jFr3cfSQbZemjFuKX50gLS45qlQ0R0Bq/view?usp=sharing

Thanks for your response!
Actually SchoolYear will not use in slicer that will be in chart and remaining categories will be use in slicer.

PFA sampleData.
I am not able to attach document. How I can attach?

Moderator v-qiuyu-msft
Moderator

Re: Need help in DAX

Hi @TejeshGour

 

Thank you for your information. I'm able to view the sample data shared by you here: https://drive.google.com/file/d/1jFr3cfSQbZemjFuKX50gLS45qlQ0R0Bq/view

 

Would you please clarify the desired results based on this data? 

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Tejesh_Gour Regular Visitor
Regular Visitor

Re: Need help in DAX

Given below is my requirement and as you can see year is a first category and second category will be select from slicer.

DynamicTab2.png

 

Moderator v-qiuyu-msft
Moderator

Re: Need help in DAX

Hi @Tejesh_Gour

 

It looks like the Race, Gender, Ethinicity, School and Grade are not the legends of the chart visual, right? 

 

If they are buttons, you can create different bookmarks to display the chart with different category, then link the button to desired bookmark. See: https://docs.microsoft.com/en-us/power-bi/desktop-bookmarks

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Tejesh_Gour Regular Visitor
Regular Visitor

Re: Need help in DAX

I got your point but I am trying to avoint charts and covering space in report.

Please check my first description where my DAX is not returning data.

Calculated Column1:= var StudentCount1 = CALCULATE ( DISTINCTCOUNT(FactGrades[DimStudentsWid]), FILTER ( VALUES( FactGrades[PercentGradeReceived]) , COUNTROWS ( FILTER ( 'DimReportingConfig', FactGrades[PercentGradeReceived] >= 'DimReportingConfig'[MinValue] && FactGrades[PercentGradeReceived] < 'DimReportingConfig'[MaxValue]&&NOT(ISBLANK(FactGrades[PercentGradeReceived])) ) ) > 0 ) ) RETURN IF ( HASONEVALUE(SelectiomTable[Type]), SWITCH ( VALUES( SelectiomTable[Type] ), "SchoolYear", CALCULATE ( StudentCount1, TREATAS ( VALUES( SelectiomTable[VALUES] ),SectionEnrollment[SchoolYear] ) ), "GradeLevel", CALCULATE ( StudentCount1, TREATAS ( VALUES( SelectiomTable[VALUES] ), SectionEnrollment[GradeLevel]) ) ),0 )

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors