Forum Discussion

SBIM's avatar
SBIM
Helper I
3 years ago
Solved

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.

 

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.

 

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.

  • 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] ) )

     

1 Reply

  • 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] ) )