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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

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 days passed till now.

 

Case | Latest comment date | Case type | Time passed till now

1 | 03-18-2022 09:56:36 AM | A | 97 hours

2 | 03-19-2022 15:35:23 PM | B | 3 days

3 | 03-21-2022 20:31:05 PM | C | 1 days

 

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

 

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") 
 
Thank you!

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

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:

vyalanwumsft_0-1648176689477.png


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:

vyalanwumsft_1-1648177042523.png


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.

View solution in original post

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

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:

vyalanwumsft_0-1648176689477.png


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:

vyalanwumsft_1-1648177042523.png


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.

amitchandak
Super User
Super User

@Anonymous , My advice would be duplicate and split this column in power query. You will get a nueric column with hour. Then you can easily apply this logic

Split Column Power Query: https://youtu.be/FyO9Vmhcfag

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

This would be a way, but I don't want to overload the report. I am pretty sure a proper DAX similar to mine can be written.

 

Anyone? 

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors