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
Anonymous
Not applicable

Can anyone assist on this dax. i need last date's , distinct id counts of having zero average .

IDDates Average
301-10-2022 0
101-10-2022 110
202-10-2022 74
401-10-2022 91
102-10-2022 100
201-10-2022 0
402-10-2022 0
104-10-2022 0
204-10-2022 0
304-10-2022 216
501-10-2022 0
1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

You can try the following methods.

 

Measure = 
CALCULATE (
    DISTINCTCOUNT ( 'Table'[ID] ),
    FILTER ( ALL ( 'Table' ), [Dates] = MAX ( 'Table'[Dates] ) && [Average] = 0 )
)

 

vzhangti_0-1672739417183.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
fseabrook92
Frequent Visitor

Could you try something like this....

 

First, create an expression that will return the distinct count of ID values where the count of rows with zero values in the Average column is greater than 0:

DistinctCountOfID =
CALCULATE(
    DISTINCTCOUNT(Table[ID]),
    FILTER(
        Table,
        CALCULATE(
            COUNT(Table[Average]),
            Table[Average] = 0
        ) > 0
    )
)

 

Then, get the last date, you can use the MAX function. Here's an example of how you can use it:

LastDate =
MAX(Table[Dates])

 

Finally, combine these measures, you can create a new measure that uses the values returned by these measures. For example:

CombinedMeasure =
"Last Date: " & LastDate & ", Distinct Count of ID: " & DistinctCountOfID

 

This will create a new measure called "CombinedMeasure" that will display the last date and the distinct count of ID values as a string.

Anonymous
Not applicable

thanks for update , but value needed for last date only 

@Anonymous 
Ok but the same ID/Date combination is duplicated many times. There must be another column involved in the filter context of table. Please advise

1.png

 

Anonymous
Not applicable

ok its a sample table. my mistake

i need last date zero count , and disticnt value count from id.

i have three measure also seperately, how to join all , (last dates , distict count by id  and countrows =0)
as per below table answer should be 2

IDDates Average
301-10-2022 0
101-10-2022 110
202-10-2022 74
401-10-2022 91
102-10-2022 100
201-10-2022 0
402-10-2022 0
104-10-2022 0
204-10-2022 0
304-10-2022 216
501-10-2022 0

Hi, @Anonymous 

 

You can try the following methods.

 

Measure = 
CALCULATE (
    DISTINCTCOUNT ( 'Table'[ID] ),
    FILTER ( ALL ( 'Table' ), [Dates] = MAX ( 'Table'[Dates] ) && [Average] = 0 )
)

 

vzhangti_0-1672739417183.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous 
Please try

Zero Average Cout =
SUMX (
    VALUES ( 'Table'[ID] ),
    VAR CurrentIDTable =
        CALCULATETABLE ( 'Table' )
    VAR MaxDate =
        MAXX ( CurrentIDTable, 'Table'[Date] )
    VAR AverageTable =
        ADDCOLUMNS ( CurrentIDTable, "@Average", [Average] )
    VAR ZeroAverageTable =
        FILTER ( AverageTable, [@Average] = 0 )
    VAR LastZeroDate =
        MAXX ( ZeroAverageTable, 'Table'[Date] )
    RETURN
        IF ( LastZeroDate = MaxDate, 1 )
)
tamerj1
Super User
Super User

Hi @Anonymous 
If [Average] is a measure you can try

Zero Average Cout =
COUNTROWS (
    DISTINCT (
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[ID], 'Table'[Date], "@Average", [Average] ),
            --or SUMMARIZE ( 'Table', 'Table'[ID], 'Date'[Date], "@Average", [Average] ),
            [@Average] = 0
        )
    )
)

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors