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

Count depening date

Hi all,

 

I'm trying to extract the KPI of Quality service. To extrat the % i need to count the total orders for the last day in the dataset and count the incidents for the last day too. The question is, I don't know how to count dependig to date in a measure.

To have the last day in the dataset doing a MAX of the date is enought but I don't know how to implement that in a measure to have this condition. 

 

Thanks in advance

1 ACCEPTED SOLUTION

@Anonymous

 

Maybe this formula is better:

 

Incidenciasultimodia =
VAR _Maxdate =
MAX ( 'Dataset'[Transformed DATA] )
RETURN
CALCULATE (
COUNT ( 'Dataset'[TIPO] );FILTER('Dataset';
'Dataset'[Transformed DATA] = _Maxdate || LEFT( 'Dataset'[TIPO], 2) = "AB"
))

View solution in original post

5 REPLIES 5
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

Could you please mark the proper answers as solutions?

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
themistoklis
Community Champion
Community Champion

@Anonymous

 

You can try the following measure:

 

Measure =
VAR _Maxdate =
    MAX ( 'Table'[Reference_Date] )
RETURN
    CALCULATE (
        COUNT ( 'Table'[Order_ID] ),
        'Table'[Reference_Date] = _Maxdate
    )

 

Anonymous
Not applicable

@themistoklis

 

Thanks for your help it helps a lot 🙂

 

Related to that is it possible to add more conditions? for example now, i have the condition of the date but i want to add for example other like. Count if other column starts with AN por example.

 

 
Incidenciasultimodia =
VAR _Maxdate =
MAX ( 'Dataset'[Transformed DATA] )
RETURN
CALCULATE (
COUNT ( 'Dataset'[TIPO] );FILTER('Dataset';
'Dataset'[Transformed DATA] = _Maxdate || 'Dataset'[TIPO] = "AN%"
))
 

 

Now looks like this but is not working or showing an error

@Anonymous

 

No problem at all.

 

You can add other conditions as well.

I think the percenrage symbol is causing the error.

 

Change the formula to this one:

Incidenciasultimodia =
VAR _Maxdate =
MAX ( 'Dataset'[Transformed DATA] )
RETURN
CALCULATE (
COUNT ( 'Dataset'[TIPO] );FILTER('Dataset';
'Dataset'[Transformed DATA] = _Maxdate || SEARCH("AN", 'Dataset'[TIPO],,0) <> 0
))

 

@Anonymous

 

Maybe this formula is better:

 

Incidenciasultimodia =
VAR _Maxdate =
MAX ( 'Dataset'[Transformed DATA] )
RETURN
CALCULATE (
COUNT ( 'Dataset'[TIPO] );FILTER('Dataset';
'Dataset'[Transformed DATA] = _Maxdate || LEFT( 'Dataset'[TIPO], 2) = "AB"
))

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.