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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Raul
Post Patron
Post Patron

Apply filter to a measure

Hello forum!

I need your help for the following measure. I want to break down the total of a column by the values of the records that compose it in a matrix visualization:

 

Captura.JPG

 

For exemple: the total of column FACT must be distributed between the records for the TIPUS COLABORADOR column. I created a new measure called DESFACT with the formula of the image but the total value is not the same that the column FACT and the distrubution is not correct either. The Total columns on the right are correct and the distribution is correct too, but for every type of document (column TIPUS with de BONO and EXPED values) are not correct. What is wrong? I don't know how to filter on the formula of the new measure.

 

This is the DAX formula:

DESFACT =
   VAR TotalFAC = CALCULATE(SUM(Tabla1[FACT]);ALLSELECTED(Tabla1))
   VAR TotalCOST = CALCULATE(SUM(Tabla1[COST]);ALLSELECTED(Tabla1))
   RETURN
       (TotalFAC * SUM(Tabla1[COST]))/ TotalCOST

 

Thanks!

1 ACCEPTED SOLUTION

I found the solution. The measure must have the following formula:

 

DESFACT =
  VAR TotalFAC = CALCULATE(SUM(Tabla1[FACT]);ALLSELECTED(Tabla1[COLABORADOR]))
  VAR TotalCOST = CALCULATE(SUM(Tabla1[COST]);ALLSELECTED(Tabla1[COLABORADOR]))
RETURN
   (TotalFAC * SUM(Tabla1[COST]))/ TotalCOST

 

Thanks @MFelix for your help!

View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @Raul,

 

try to change you formula to something like this:

 

DESFACT =
VAR TotalFAC =
    CALCULATE (
        SUM ( Tabla1[FACT] );
        ALLSELECTED ( Tabla1 );
        FIRSTNONBLANK ( Tabla1[TIPUS]; SUM ( Tabla1[FACT] ) )
    )
VAR TotalCOST =
    CALCULATE (
        SUM ( Tabla1[COST] );
        ALLSELECTED ( Tabla1 );
        FIRSTNONBLANK ( Tabla1[TIPUS]; SUM ( Tabla1[FACT] ) )
    )
RETURN
    ( TotalFAC * SUM ( Tabla1[COST] ) )
        / TotalCOST

Check if it works, did not tried in the computer.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Thanks for your answer @MFelix,

Now, the totals for the columns FACT and DESFACT have the same value but don't appear the distribution for the column COLABORADOR and the Total colum of DESFACT it's not correct, like this:

 

 

Captura.JPG

I need the DESFACT column to distribute the total for the records in the COLABORADOR column and that the total is the correct one.

 

This is a summary of the table source of the Power BI file:

 

COLABORADORCOSTFACTURACIOTIPUS
  2514,85BONO
MR116,5 BONO
RC200 BONO
SM609,7 BONO
  1481,92EXPED
MR100 EXPED
RC305 EXPED
SM79,5 EXPED

 

Thank you.

 

 

I found the solution. The measure must have the following formula:

 

DESFACT =
  VAR TotalFAC = CALCULATE(SUM(Tabla1[FACT]);ALLSELECTED(Tabla1[COLABORADOR]))
  VAR TotalCOST = CALCULATE(SUM(Tabla1[COST]);ALLSELECTED(Tabla1[COLABORADOR]))
RETURN
   (TotalFAC * SUM(Tabla1[COST]))/ TotalCOST

 

Thanks @MFelix for your help!

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.