Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Count of mixed values(text-integer)

Hi,   Can anyone help me achieve the below?    I have these values in my PBi columns with my logic applied: for case type A I am counting hours passed till now, for case type B/C I am counting da...
  • v-yalanwu-msft's avatar
    4 years ago

    Hi, Anonymous ;

    My DAX below returns incorrect results like: "303 hours < 168 hours: Yes", "5 days < 7 days: No"

    IF('Source'[Case type]="A" && 'Source'[Time passed till now]>168 & " hours", "Yes","No")
    IF('Source'[Case type]="B" && 'Source'[Time passed till now]>7 & " days", "Yes","No") 
    IF('Source'[Case type]="C" && 'Source'[Time passed till now]>7 & " days", "Yes","No") 

    You could create a column :

    column = 
    var _num=CONVERT( LEFT([Time passed till now], SEARCH(" ",[Time passed till now])),INTEGER)
    return IF(('Source'[Case type]="A"&&_num>168)||
             (('Source'[Case type]="B"||'Source'[Case type]="C") &&_num>7),
             "Yes","No")

    The final output is shown below:


    My desired output would be to count for all of these cases - how many are older than 1 week?


    You could create a measure.

    count = 
    CALCULATE(COUNT([Case type]),FILTER(ALLSELECTED(Source),DATEDIFF([Latest comment date],NOW(),HOUR)>7*24))

    The final output is shown below:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.