Why does the calculated return from summary table can not show in Line Chart in Power BI?

Viewed 51

I face the problem where I created measure which has formula like below:

# Mixing Class =
VAR Temp =
    SUMMARIZE (
        'Mixing Class',
        'Mixing Class'[ClassKey],
        "NumClassTCMixing", DISTINCTCOUNTNOBLANK ( 'Mixing Class'[TC_TeacherCode] )
    )
RETURN
    COUNTX ( FILTER ( Temp, [NumClassTCMixing] >= 4 ), 'Mixing Class'[ClassKey] )

After this I drag this measure to Line Chart which show the total number of Classes through time. But the Chart show nothing (No error, No data). What is the problem here? Does my DAX code has errors? Please help me because I spend all day to fix this but nothing changes :(

This is the sample of columns in my measure:

enter image description here

enter image description here

1 Answers

This construction is more safety, try it.

# Mixing Class = 
VAR Temp = 
    ADDCOLUMNS(
        SUMMARIZE(
            'Mixing Class'
            ,'Mixing Class'[ClassKey]
       )
       ,"numOfTeachers",CALCULATE(
                            COUNTROWS(
                                DISTINCT('Mixing Class'[TC_TeacherCode])  
                            )
                         )
                     -- CALCULATE(
                     --     DISTINCTCOUNTNOBLANK(
                     --         'Mixing Class'[TC_TeacherCode]
                     -- ) -- should return the same result
RETURN 
    COUNTROWS(
        FILTER(
            Temp
            ,[numOfTeachers]>= 4
        )
     )

Alternative:

COUNTROWS(
    FILTER(
        VALUES('Mixing Class')
        , VAR dateInChart = SELECTEDVALUE(Date[DateKey])
          RETURN
              CALCULATE(
                  COUNTROWS(
                      DISTINCT('Mixing Class'[TC_TeacherCode])  
                   )
                   ,'Mixing Class'[DateKey]=dateInChart 
              )>=4
)
Related