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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

Follow on LinkedIn
@ 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])

Follow on LinkedIn
@ 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. 


Follow on LinkedIn
@ 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.