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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Calculate a measure using 2 different selections from the same table as filters

I am in a pickle here... someone handed this to me and said solve this or else... Ive been trying to figure this out for the past day or so I don't know if this is even possible, so here is goes.

 

Here is my data model, nothing fancy so far.

talleslessa_0-1616109439373.png

 

Here is my Report page/dash

 

talleslessa_1-1616109512771.png

 

The selected card ("nova marg%") has the following calculation, all the measures are calculated with values from "Fvendas" 

 

talleslessa_2-1616109893289.png

However, as it is, the value returned is wrong. I've been messing with "edit interactions" and for each single value it partially works (before the final calculation). If i set the card to be filtered by the green slicer only [precoreco] and [ajusteimp] turn out right, however [cstunit] value is wrong. And if  I set the card to filtered by the blue slicer only it is the other way around.

 

And if filtered by both it just crashes I think it is because they are, after all, on the same table and column (Dprodutos[item_desc]) so it cannot be filtered based on a selection from the same column twice. They only show different values because they  have a filter applied to them based on the column Dprodutos[mp] , if it is set to 1 it returns the blue sclicer values and if mp = 0 it returns the values shown on the green slicer.

Here goes my Dprod table for context:

 

talleslessa_3-1616110735144.png

 

I have been looking into SEECTEDVALUE() to use together with CALCULATE(), nort sure even If it works or how to make this work with 2 different selections.

 

To get the value that I need, [Preço Recomendado] and [AjusteImp] must be filtered using the value selected from the green slicer to the right while [CstUnit] must be filtered based on the value on the blue slicer. Is there a way to do so? even if i need to change my data structure or w/e.

 

Thanks in advance

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

The method you used before is correct. Actually I mean you could create a calculated table via ALLSELECTED() not getting the selected value in slicer like this:

New Table=DISTINCT(ALLSELECTED('MP'[Desc],MP[VALOR]))

3.22.new table.PNG

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

The method you used before is correct. Actually I mean you could create a calculated table via ALLSELECTED() not getting the selected value in slicer like this:

New Table=DISTINCT(ALLSELECTED('MP'[Desc],MP[VALOR]))

3.22.new table.PNG

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Anonymous ,

 

To my knowledge, It's suggested to add a new table as you used before. You could use ALLSELECTED() to select necessary columns as a calculated table instead of duplicating the whole table.

 

3.22.5.two slicers.PNG

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hello! thanks for your help. How would I use allselected () ? I've been trying to figure it out, however im prettu new to dax  therefore i am having some troubles. Here is what I have done:

I have created a new column that is a copy of the one used in the slicer (OL =MP[descrição])

talleslessa_0-1616411819232.png

Changed the structre to 

talleslessa_1-1616411835351.png

 

And the measure to : 

talleslessa_2-1616411917338.png

 

 

my logic here (which is probably wrong) is with ALLSELECTED() i have created a new table with my key and the column i want to filter out,  that table is then filteres using FILTER() using the SELECTEDVALUE() of the slicer selection. then changed my sclier to use MP[descricao] as its field.

 

but if the silcers selections are different from each other i get blanks, otherwise I get an error stating that PBI could not convert the selected value (text) into a true/false argument.

 

talleslessa_3-1616412287353.png

 

Anonymous
Not applicable

I figured it out , however there is an extra step that I would like to avoid so I want some input from you guys.

 

Simplyfing things here is the mock up of my previous model.

talleslessa_0-1616191391844.png

 

What I wanted to do was make the card in the middle be filtered by the selection from both slicers (OL to the right and MP to the left).

 

talleslessa_1-1616191520827.png

 

But why so ? because inside the measure used for the card contains 2 variables and each of them needed to be filtered by one, but not the other slicer. For instance, the mock up measure i used was :

CONTA =
VAR FATOROL = VENDA[SALE]  //this one was to be filtered by the OL slicer only
VAR FATORMP = VENDA[SALE] // this one was to be filtered by the MP sclicer only
RETURN
FATOROL/FATORMP

 

So when I selected a value from both slicers it would give me a measure that was the result from a combination of the selection from both slicers.

 

However both slicers where filtering the same column on the same table (they were both set from MP[descrição], and no, using multiple selections would not solve my issue) So in short what i needed was for the variables of a measure to be filtered based on multiple selections from the same column.

 

Which I could not make it work... so to fix this I duplicated the OL table, called it MP, changed the data structure to this :

talleslessa_3-1616192257991.png

And changed the measure to 

 

CONTA =
VAR FATOROL = CALCULATE(VENDA[SALE],REMOVEFILTERS(MP[Descrição]))
VAR FATORMP = CALCULATE(VENDA[SALE],REMOVEFILTERS(OL[dESCRIÇÃO]))
RETURN
FATOROL/FATORMP

 

So the first variable ignores the selection from the MP table and the second ignores the OL table. And now it works !!!!

 

But I had to duplicate an entire table to do this ...  Now my question is... is there any fancier way of achieving the same result without dupplicating the table and using a 1:1 relationship?

 

 

 

 

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors