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
smko
Helper I
Helper I

Context transition on fact table

I am aware context transition should not be performed on fact table due to possibility of duplicate rows. The row context of duplicate rows will become one unique filter context, this I do understand. I just want to understand how [Wrong] measure is being calculated for MP=Lazada, how the result become double of [Correct]. Appreciate any technical answers on this.

 

Dataset

smko_1-1665403167475.png

Visual result

smko_0-1665405103094.png

 

Sales = SUMX('Sales', 'Sales'[Quantity] * 'Sales'[UnitPrice])

Correct = SUMX('Sales', 'Sales'[Quantity] * 'Sales'[UnitPrice] * Sales[Com%])

Wrong = SUMX(Sales, Sales[Com%] * [Sales])

1 ACCEPTED SOLUTION
mangaus1111
Solution Sage
Solution Sage

In this example there is a multiplication between a measure [Sales] and a column [Com%], instead a multiplication between 2 columns. The scalar value of the measure [Sales] is always 16 beacause is independent from the row context.

 

Please hit the thumbs up & mark it as a solution if it helps you. Thanks.

 

MP                [Sales]           Com%

LAZADA          16        *       0.075    =     1.2  

LAZADA          16        *       0.075     =     1.2 

                                                              _________

                                                                2.4

View solution in original post

10 REPLIES 10
mangaus1111
Solution Sage
Solution Sage

In this example there is a multiplication between a measure [Sales] and a column [Com%], instead a multiplication between 2 columns. The scalar value of the measure [Sales] is always 16 beacause is independent from the row context.

 

Please hit the thumbs up & mark it as a solution if it helps you. Thanks.

 

MP                [Sales]           Com%

LAZADA          16        *       0.075    =     1.2  

LAZADA          16        *       0.075     =     1.2 

                                                              _________

                                                                2.4

mangaus1111
Solution Sage
Solution Sage

hi @smko ,

 

a measure has no row context, then if you use the [Wrong] measure you get the following calculation:

MP                [Sales]           Com%

LAZADA          16        *       0.075    =     1.2  

LAZADA          16        *       0.075     =     1.2 

                                                              _________

                                                                2.4

mangaus1111
Solution Sage
Solution Sage

Hi @smko ,

 

the measure Wrong = SUMX(SalesSales[Com%] * [Sales]) is wrong and give you the double of the correct one, because "a measure is an expression where there is no row context".

The scalar value computed by the measure [Sales] is always 16 by Lazada and the scalar value computed by the [Wrong] Measure is:

MP               [Sales]       Com%

 

LAZADA       16         *     0.075    =   1.2

LAZADA       16        *      0.075    =   1.2

                                                    --------------

                                                          2.4

 

 

Please hit the thumbs up & mark it as a solution if it helps you. Thanks.

 

aj1973
Community Champion
Community Champion

Hi @smko 

Where is this column coming from?

aj1973_0-1665404033899.png

try to use the column Date from the Table of the dataset

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Ops sorry, thats the attribute from my calendar dimension table, I have change to the date column from sales table

aj1973
Community Champion
Community Champion

Therefore you either add MonthYearNum to the fact table and use it in your visual or change the relationship to bidirectional between the Fact table and Calendar Table

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

The column [Date] and [MP] in the visual are from fact table

aj1973
Community Champion
Community Champion

Here you go

aj1973_0-1665407753075.png

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

I just want to understand how the [Wrong] measure come up with wrong result. I already knew the correct DAX to get the right result as shown in [Correct] measure

aj1973
Community Champion
Community Champion

Very good question, I invite to watch theses videos to explain it in details

https://www.youtube.com/watch?v=lMuDz6ViU1w

https://www.youtube.com/watch?v=lX2ztEh3tuA

https://www.youtube.com/watch?v=Nm9x83J-SBk

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

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.