cancel
Showing results 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

Anonymous
Not applicable

## How to create measure?

I have 3 tables: Colour, Category, FactSales:

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:

But when I'm trying to use fileds from both tables it works wrong:

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
Resident Rockstar

@Anonymous -

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

Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!

Solution Sage

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

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

4 REPLIES 4
Solution Sage

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

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.

Resident Rockstar

@Anonymous -

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

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 -

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

Yes. It works perfect. Thank you!

Announcements

#### 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.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### 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
Top Kudoed Authors