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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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