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
chinthada
Helper I
Helper I

Quarterly Count with multiple filters

Hi,

I want to create a measure to show quarterly count of records with multiple filters. The data table is like below,

datatabledatatable

For this example, the result (record count) should be = 4


I tried below measure with DistinctCount

CustomMeasure = CALCULATE(DISTINCTCOUNT('VW_Water'[CC_MASTER__ID]), 'VW_Water'[Fiscal_Quarter], filter('VW_Water','VW_Water'[CC_MAST_SUBTYPE]= "E*LEAK" && 'VW_Water'[EarlyClosure]= "Double up" && 'VW_Water'[Activity]= "Complete"))

 

The output should be like this.

 

PBI VisualPBI Visual

Appreciate your help.

thanks

1 ACCEPTED SOLUTION
StevenGrenier
Frequent Visitor

The syntax for CALCULATE is CALCULATE([expression], filter, filter, filter...). You are trying to add multiple filters in the same FILTER statement by using &&. Simply add more FILTER statements and it should work.

 

CustomMeasure = CALCULATE(DISTINCTCOUNT('VW_Water'[CC_MASTER__ID]), FILTER('VW_Water','VW_Water'[CC_MAST_SUBTYPE]= "E*LEAK"), FILTER('VW_Water','VW_Water'[EarlyClosure]= "Double up"), FILTER('VW_Water','VW_Water'[Activity]= "Complete"))

 

Hope this helps!

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

The easiest would be to just apply filter or create slicers and then select.  If you are OK with this approach, then this measure will work

=DISTINCTCOUNT('VW_Water'[CC_MASTER__ID])

If you do not wish to use slicers/filters, then write this measure

=CALCULATE(DISTINCTCOUNT('VW_Water'[CC_MASTER__ID]), 'VW_Water'[Fiscal_Quarter]="Q1",'VW_Water'[CC_MAST_SUBTYPE]= "E*LEAK",'VW_Water'[EarlyClosure]= "Double up",'VW_Water'[Activity]= "Complete")

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
StevenGrenier
Frequent Visitor

The syntax for CALCULATE is CALCULATE([expression], filter, filter, filter...). You are trying to add multiple filters in the same FILTER statement by using &&. Simply add more FILTER statements and it should work.

 

CustomMeasure = CALCULATE(DISTINCTCOUNT('VW_Water'[CC_MASTER__ID]), FILTER('VW_Water','VW_Water'[CC_MAST_SUBTYPE]= "E*LEAK"), FILTER('VW_Water','VW_Water'[EarlyClosure]= "Double up"), FILTER('VW_Water','VW_Water'[Activity]= "Complete"))

 

Hope this helps!

Thanks @StevenGrenier 

As suggested adding more FILTER statements has done the trick!

@StevenGrenier 

Try

CustomMeasure = CALCULATE(DISTINCTCOUNT('VW_Water'[CC_MASTER__ID]), FILTER('VW_Water','VW_Water'[CC_MAST_SUBTYPE]= "E*LEAK" && 'VW_Water'[EarlyClosure]= "Double up" && 'VW_Water'[Activity]= "Complete"))

CustomMeasure = CALCULATE(DISTINCTCOUNT('VW_Water'[CC_MASTER__ID]),'VW_Water'[CC_MAST_SUBTYPE]= "E*LEAK", 'VW_Water'[EarlyClosure]= "Double up",'VW_Water'[Activity]= "Complete")

if you need more help make me @

Appreciate your Kudos.

amitchandak
Super User
Super User

Better you use Datesqtd or totalqtd with date table. Rest you can add to calculate

Example

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))
Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))
Next QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],1,QUARTER)))

Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,Year)))

trailing QTR = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,QUARTER))
trailing  4 QTR = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-4,QUARTER))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

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.