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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
avawhittington
Frequent Visitor

Calculating a datediff measure amount with a filter

Hey, I have a measure that takes the created date of a case and finds the difference to todays date. 

 

MaxDateDiff = DATEDIFF(max('Cases'[CreateDate2]), TODAY(),day)
 
It brings back exactly what I want... When I put it into a table I can see the partner and how far back their most recent case date was (Each partner has multiple cases). I grab the partner name from a table 'Partner'
 
Next, I put a filter on the table using the filter pane to only show the partner name and its difference date if it is between 90 and 180 days. The table does this as well.
 
Where my problem is: I want to use this in a card. I want to show the amount of partners that have their difference date 90 - 180. When I put the measure in a card it only shows "1"
 
I'm trying to show inactivity on parters
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @avawhittington ,

According to your description, it seems it involves two tables: 'Cases' and 'Partner' and you want to get the count of partners who have the cases with datediff(from case created date to today) is 90~180 days. Am I right? If yes,you can follow the steps below to get it. Please find the details in the attachment.

1. Create two measures as below

MaxDateDiff = 
VAR _selpartner =
    SELECTEDVALUE ( 'Cases'[Partner ID] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'Cases'[CreateDate2] ),
        FILTER ( ALLSELECTED ( 'Cases' ), 'Cases'[Partner ID] = _selpartner )
    )
VAR _datediff =
    DATEDIFF ( _maxdate, TODAY (), DAY )
RETURN
    _datediff
Count of partner = 
CALCULATE (
    DISTINCTCOUNT ( 'Cases'[Partner ID] ),
    FILTER ( 'Cases', [MaxDateDiff] >= 90 && [MaxDateDiff] <= 180 )
)

2. Create a card visual

yingyinr_0-1669186996905.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @avawhittington ,

According to your description, it seems it involves two tables: 'Cases' and 'Partner' and you want to get the count of partners who have the cases with datediff(from case created date to today) is 90~180 days. Am I right? If yes,you can follow the steps below to get it. Please find the details in the attachment.

1. Create two measures as below

MaxDateDiff = 
VAR _selpartner =
    SELECTEDVALUE ( 'Cases'[Partner ID] )
VAR _maxdate =
    CALCULATE (
        MAX ( 'Cases'[CreateDate2] ),
        FILTER ( ALLSELECTED ( 'Cases' ), 'Cases'[Partner ID] = _selpartner )
    )
VAR _datediff =
    DATEDIFF ( _maxdate, TODAY (), DAY )
RETURN
    _datediff
Count of partner = 
CALCULATE (
    DISTINCTCOUNT ( 'Cases'[Partner ID] ),
    FILTER ( 'Cases', [MaxDateDiff] >= 90 && [MaxDateDiff] <= 180 )
)

2. Create a card visual

yingyinr_0-1669186996905.png

Best Regards

FreemanZ
Super User
Super User

it seems the Card visual is unexpectedly filtered by other contexts, try to plot with a new measure with the code below:

CardMeasure=

CALCULATE

   SUM(TableName[Amount]),

   FILTER(

       ALL(TableName),

        [MaxDateDiff]>=90 

          && [MaxDateDiff]<=180

    )

)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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