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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
luisfarantes
Frequent Visitor

Filter in Calculate: How can I use values from a column to apply a filter while using CALCULATE?

Hi people!

 

I'm new to Power BI and i'm having trouble to use the filter in the CALCULATE formula.

 

I have a table that contains these columns:

Client id A, Client id B and Total consumption.

Some times we charge our clients through the "Client id A" , other times through "Clients id B".

I created a conditional column that shows wich id we should charge called "Charged id", but i need to create a measure to aggregate this column by charged id.

I tried to use the CALCULATE formula, but i have thousands of Charged id numbers, so is basically impossible to create a different measure for each one. Is there a way to use the CALCULATE formula filter using each charged id?

If the answer is no, is there a formula that I can aggregate the sum of consumption by Charged id?

 

Thank you! 

 

1 ACCEPTED SOLUTION
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @luisfarantes 

 

So far you should in a first place creat the following 

 

Mikelytics_2-1668457689954.png

 

 

Total Consumption =

SUM(table[agendas batch])

 

Then you go in the report view 

Mikelytics_1-1668457662044.png

 

somewhere on the right side you should find you created measure

 

Now you create a matrix visual. you put the measure in the "Value" area and the charge id into the "Rows" area

Mikelytics_3-1668457757972.png

 

THen you shoul have a aggregated list of chaged ID with total consumption.

 

Best regards

Michael

-----------------------------------------------------

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

@ me in replies or I'll lose your thread.

 

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

3 REPLIES 3
Mikelytics
Resident Rockstar
Resident Rockstar

Hi @luisfarantes 

 

So far you should in a first place creat the following 

 

Mikelytics_2-1668457689954.png

 

 

Total Consumption =

SUM(table[agendas batch])

 

Then you go in the report view 

Mikelytics_1-1668457662044.png

 

somewhere on the right side you should find you created measure

 

Now you create a matrix visual. you put the measure in the "Value" area and the charge id into the "Rows" area

Mikelytics_3-1668457757972.png

 

THen you shoul have a aggregated list of chaged ID with total consumption.

 

Best regards

Michael

-----------------------------------------------------

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

@ me in replies or I'll lose your thread.

 

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
Mikelytics
Resident Rockstar
Resident Rockstar

^Hi @luisfarantes ,

 

Can you maybe provide qn wasy sample of your data and an expected outcome, for example in a table or matrix?

 

Best regards

Michael

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Hi  , how u doing? 

Sure, here is the table:

Where "nome participante" is the Client id A, and "nome detentor" is the Client id B. The column called "nome cobrado" is the Charged id, and the "agenda batch" is the total consumption.

I was able to create a calculated column with the following formula:

Total batch = CALCULATE(SUM('Agenda Batch - Out'[agendas batch]), FILTER('Agenda Batch - Out', 'Agenda Batch - Out'[Nome Cobrado] = EARLIER('Agenda Batch - Out'[Nome Cobrado])))

But I wasn't able to created it as a Measure, and in this case i need it as a Measure because later on i will apply another measure that is going to be de discount based on total consumption for each client.

 

 

 

 

 

luisfarantes_2-1668458166626.png

@Mikelytics

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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