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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

How to create measure?

I have 3 tables: Colour, Category, FactSales:tables.jpg

I have to create measure, to Sum amount of "Red" sales. Every row should display this value.

I tried to do it:

Measure = SUM(FactSales[Amount])
MeasureRed = CALCULATE( [Measure]; FILTER(ALL(Colour); Colour[Colour] = "Red" ) )
This is OK for this case:
red-1.jpg

 

But when I'm trying to use fileds from both tables it works wrong:red-2.png

I expect to get 20 in each row. How can I create measure correctly and combine two ALL() functions for two tables?

 
 

 

 

 

2 ACCEPTED SOLUTIONS
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

Does this accomplish your request?

MeasureRed =
CALCULATE (
    [Measure],
    ALL ( FactSales ),
    Colour[Colour] = "Red"
)





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

kentyler
Solution Sage
Solution Sage

 

What's happening is that, looking at the first line in your "both fields" example, cross_plus_red.png

Cross is filtering out 4 rows from factsales

then red filters, from within those rows, one row of red...whose amount is 6, which is what you see in your table.

So as well as getting All() from the color table, you need to get ALL() from the fact table

something like

MeasureRed = CALCULATE( [Measure];ALL(FactSales); FILTER(ALL(Colour); Colour[Colour] = "Red" ) )





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


View solution in original post

4 REPLIES 4
kentyler
Solution Sage
Solution Sage

 

What's happening is that, looking at the first line in your "both fields" example, cross_plus_red.png

Cross is filtering out 4 rows from factsales

then red filters, from within those rows, one row of red...whose amount is 6, which is what you see in your table.

So as well as getting All() from the color table, you need to get ALL() from the fact table

something like

MeasureRed = CALCULATE( [Measure];ALL(FactSales); FILTER(ALL(Colour); Colour[Colour] = "Red" ) )





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Anonymous
Not applicable


@kentyler wrote:

MeasureRed = CALCULATE( [Measure];ALL(FactSales); FILTER(ALL(Colour); Colour[Colour] = "Red" ) )



Thank you. This is exact what I want.

ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

Does this accomplish your request?

MeasureRed =
CALCULATE (
    [Measure],
    ALL ( FactSales ),
    Colour[Colour] = "Red"
)





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Anonymous
Not applicable


@ChrisMendoza wrote:

@Anonymous -

Does this accomplish your request?

MeasureRed =
CALCULATE (
    [Measure],
    ALL ( FactSales ),
    Colour[Colour] = "Red"
)

Yes. It works perfect. Thank you!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors