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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
TejeshGour
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
v-qiuyu-msft
Community Support
Community Support

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.

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)

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

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.

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?

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

 

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.

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 )

Hi @Tejesh_Gour

 

From your source data (https://drive.google.com/file/d/1jFr3cfSQbZemjFuKX50gLS45qlQ0R0Bq/view), the table FactGrades doesn't contain Type and VALUEs columns, I guess you do transform for the table in Query Editor. 

 

As I don't know how the data model it is, it's hard to provide further help. If possible, please share the pbix file and clarify the desired results of Calculated Column1. 

 

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.

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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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