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
Anonymous
Not applicable

CALCULATE with filter measure by condition

Hi guys!

 

What is the correct way to do what I'm attempting?

I have 2 measures of SUMS (Soma de Estoque and Soma de Uso).

I want to bring only the values from Soma de Estoque, where the Soma de Uso are below 500.

 

 

2019-09-01 18_00_35-Treino - Power BI Desktop.png


Thanks in advance!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Probably something along the lines of:

 

Measure =
VAR __table = SUMMARIZE('Table',[PN],[Vendor],"__SomadeEstoque",[Soma de Estoque],"__SomadeUso",[Soma de Uso])
RETURN
SUMX(FILTER(__table,[__SomadeUso]< 500),[__SomadeEstoque])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

You also can use "visual filter" with "Soma de Uso" below 500.

 

PGAndrade
Frequent Visitor

Hello @Anonymous sup?
In this case the "Soma de Uso" realy need to be a measure? If it could be a  calculated column then you can use it as a Filter like in the folowing expression:
CALCULATE([Soma de Estoque]; TableName[Soma de Uso] > 500)


If they must be measures a straighfoward solution is the following:
Low Usage = IF([Soma de Uso] < 500; [Soma de Estoque]; BLANK())

 

Anonymous
Not applicable

@PGAndradehi!

I ended up doing it like that: Low Usage = IF([Soma de Uso] < 500; [Soma de Estoque]; BLANK())

But that affected my performance for a lot of data.

 

 

Let me see @Anonymous,
Have you tried the @Greg_Deckler solution? Maybe that one has a better performance, if you had some issues understanding the expression I could explain it to you.

Greg_Deckler
Super User
Super User

Probably something along the lines of:

 

Measure =
VAR __table = SUMMARIZE('Table',[PN],[Vendor],"__SomadeEstoque",[Soma de Estoque],"__SomadeUso",[Soma de Uso])
RETURN
SUMX(FILTER(__table,[__SomadeUso]< 500),[__SomadeEstoque])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Did you create a new table with the SUMMARIZE and then created a measure with RETURN?

So yes and no, it creates a table in memory as a variable, not in the data model. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.