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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate number of days if condition is matched

Hi All,

 

I have to calculate number of days if condition is matched. Please find the below table:

 

1. Columns name are : Date , brand, Average coverage 

2. Average coverage is a calculated metrics and the used formula as (metrics = AVERAGE('Promoter article'[Coverage]) )

3. Now if I select any brand like "Aardee" then for 1st march 2022 to 31st march 2022 - matched and not matched value will count.

 

Aardee = Matched = 10, not matched = 17

 

DateBrandAvg Coveragecondition
3/1/2022Aardee83%Matched
3/2/2022Aardee42%not matched
3/3/2022Aardee92%Matched
3/4/2022Aardee79%not matched
3/5/2022Aardee71%not matched
3/6/2022Aardee71%not matched
3/7/2022Aardee92%Matched
3/8/2022Aardee58%not matched
3/10/2022Aardee92%Matched
3/11/2022Aardee79%not matched
3/12/2022Aardee79%not matched
3/13/2022Aardee29%not matched
3/14/2022Aardee58%not matched
3/15/2022Aardee58%not matched
3/17/2022Aardee58%not matched
3/18/2022Aardee0%not matched
3/19/2022Aardee57%not matched
3/20/2022Aardee50%not matched
3/21/2022Aardee92%Matched
3/22/2022Aardee92%Matched
3/24/2022Aardee92%Matched
3/25/2022Aardee79%not matched
3/26/2022Aardee57%not matched
3/27/2022Aardee71%not matched
3/28/2022Aardee92%Matched
3/29/2022Aardee83%Matched
3/31/2022Aardee92%Matched

 

Thanks

Shipra

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

Hi @Anonymous ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR _month =
    MONTH ( MAX ( 'Table'[Date] ) )
VAR _year =
    YEAR ( MAX ( 'Table'[Date] ) )
RETURN
    CALCULATE (
        COUNT ( 'Table'[condition] ),
        FILTER (
            ALL ( 'Table' ),
            MONTH ( MAX ( 'Table'[Date] ) ) = _month
                && YEAR ( MAX ( 'Table'[Date] ) ) = _year
                && 'Table'[Brand] = SELECTEDVALUE ( 'Table'[Brand] )
                && 'Table'[condition] = SELECTEDVALUE ( 'Table'[condition] )
        )
    )

vpollymsft_0-1653012203417.png

If I have misunderstood your meaning, please provide more details with your desired output and your pbix file without privacy information.

 

Best Regards

Community Support Team _ Polly

 

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-rongtiep-msft
Community Support
Community Support

Hi @Anonymous ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR _month =
    MONTH ( MAX ( 'Table'[Date] ) )
VAR _year =
    YEAR ( MAX ( 'Table'[Date] ) )
RETURN
    CALCULATE (
        COUNT ( 'Table'[condition] ),
        FILTER (
            ALL ( 'Table' ),
            MONTH ( MAX ( 'Table'[Date] ) ) = _month
                && YEAR ( MAX ( 'Table'[Date] ) ) = _year
                && 'Table'[Brand] = SELECTEDVALUE ( 'Table'[Brand] )
                && 'Table'[condition] = SELECTEDVALUE ( 'Table'[condition] )
        )
    )

vpollymsft_0-1653012203417.png

If I have misunderstood your meaning, please provide more details with your desired output and your pbix file without privacy information.

 

Best Regards

Community Support Team _ Polly

 

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

 

 

Whitewater100
Solution Sage
Solution Sage

Hi:

Please see attached file for hopeful solution. Good luck..

https://drive.google.com/file/d/1O3t8cwNOd2tcM07IZ-oKE2K57setUZdj/view?usp=sharing 

Condition Not Matched = CALCULATE(COUNTROWS('Table'),'Table'[condition] = "not matched")

Then I used measures to sum the hits under each result.

 

Whitewater100_0-1652789940230.png

Cond Matched = SUM('Table'[Condition Matched])
Cond Not Matched = SUM('Table'[Condition Not Matched])
daXtreme
Solution Sage
Solution Sage

Perhaps something like...

[Matched Days] =
CALCULATE(
    DISTINCTCOUNT( T[Date] ),
    KEEPFILTERS(
        T[Condition] = "matched"
    )
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors