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

How do I aggregate a column in a table

I am trying to create a column to aggregate the data below by market and fiscal month. In Excel it is quite easy using a COUNTIFS function i.e. MonthlyLeads = COUNTIFS(B:B,B2,J:J,J2) But I can't figure out the equivalent DAX to do this.

 

IDMarketapptdateFiscalDayOfMonthFiscalDayOfYearFiscalWeekOfYearfiscalMonthOfYearfiscalQuarterfiscalYearFiscalMonthKeyMonthlyLeads
118554ORLThursday,  January 28, 2021262641120211/1/2021330
152472ORLMonday,  January 3, 20222211120221/1/2022343
123318JAXWednesday,  March 10, 20211167103120213/1/2021234
183521TAMPAMonday,  August 22, 202223233348320228/1/2022190
186942SARWednesday,  October 5, 2022427740104202210/1/2022274
182727SARFriday,  August 12, 202213223328320228/1/2022111
186301SARSaturday,  September 24, 202228266389320229/1/2022107
132147JAXTuesday,  June 1, 20213150226220216/1/2021162

 

To give a little context here I have the financial account data by Month and Market and we want to do some calculations like marketing cost per lead etc. I can easily do a lookup of the marketing spend, but I have to average it out to use in my measure then divide by the count of leads. So when I display that in a table I get good data for the individaul markets and months, but the totals are way too low since it is taking the average total divided by all leads.

SBIM_0-1669731394563.png

 

I have also tried to just join the tables on Market and make a single measure but since I am using measures from two tables and slicing by market and month I am getting results that are way off.

SBIM_1-1669731935007.png

 

Since I have the aggregate marketing cost in my leads table, via lookup, I want to also have an aggregate of leads. That way they can both be averaged in my measure and elminate the discrepancy that only exists in the total.

 

If there is an easier option I am open to that but like I said in Excel this would be easy. Any help here would be appreciated.

1 ACCEPTED SOLUTION
SBIM
Helper I
Helper I

I managed to figure it out. I needed to add a column that combines both criteria and then calculates it using a COUNTA and all ALLEXCEPT

MarketMonth = ils_IssuedLeads[Market] & " - " & ils_IssuedLeads[FiscalMonthKey]
2 test = CALCULATE ( COUNTA ( ils_IssuedLeads[MarketMonth] ), ALLEXCEPT(ils_IssuedLeads, ils_IssuedLeads[MarketMonth] ) )
SBIM_0-1669736070597.png

 

View solution in original post

1 REPLY 1
SBIM
Helper I
Helper I

I managed to figure it out. I needed to add a column that combines both criteria and then calculates it using a COUNTA and all ALLEXCEPT

MarketMonth = ils_IssuedLeads[Market] & " - " & ils_IssuedLeads[FiscalMonthKey]
2 test = CALCULATE ( COUNTA ( ils_IssuedLeads[MarketMonth] ), ALLEXCEPT(ils_IssuedLeads, ils_IssuedLeads[MarketMonth] ) )
SBIM_0-1669736070597.png

 

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.