Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello Gen,
I'm trying to do simple pivot table with DAX. That's very simple for you all but it's very hard for me to make it. It taking almost 1 week but still can't figure out. I would like to show some data from different table on pivot table column. So i use lookup column on my primary table but total result is wrong. I think it should be use measure instead of lookup. But i have no idea to how to get the value from another table using with measure
Existing Lookup
LOOKUPVALUE(PlanSales[Plan Sales Amount],PlanSales[Year],YEAR(Evaluation[Ord. Date]),[Country Code],Evaluation[Sell-to Country Code])
I need to retrive value from "PlanSales" Table base on "Calendar[Year]" and "Sell_to_Country[Sell-to Alpha-2 Code] filter. I try to use below DAX but it giving me Max value even my Calendar Year is 2019.
mPlan Sales Amount:=CALCULATE (
MAX(PlanSales[Plan Sales Amount]),ALLEXCEPT('Calendar','Calendar'[Year]),ALLEXCEPT(Sell_to_Country,Sell_to_Country[Sell-to Country]))
Plan Sales Table
Year | Country Code | Plan Sales Amt. |
2019 | AU | 100 |
2020 | AU | 150 |
2019 | SG | 150 |
2020 | SG | 120 |
Sample Pivot
You can find the sample excel file at here https://www.mediafire.com/file/tl7lfhzjepyemtj/Sampl2.xlsx/file
Solved! Go to Solution.
Hi @yukon ,
We can use the following measures to meet your requirement.
Measure 1:=SUMX(VALUES(Sell_to_Country),CALCULATE(MAX(Evaluation[PSalesAmt])))
Measure 2 = IF (
ISFILTERED ( 'Evaluation'[Sell-to Country Code] )
|| ISFILTERED ( 'Evaluation'[Sell-to Customer Name] ),
CALCULATE ( AVERAGE ( Evaluation[PSalesAmt] ) ),
MAXX (
GROUPBY (
ALLSELECTED ( 'Calendar' ),
'Calendar'[Year],
'Calendar'[Week of Year]
),
CALCULATE ( AVERAGE ( Evaluation[PSalesAvgAmt] ) )
)
)
Then We can use the two measures to replace [PSalesAmt] and [PSalesAvgAmt], the result like this,
If you have any other questions, please kindly ask here and we will try to resolve it.
BTW, excel file as attached.
Best regards,
Hi @yukon ,
We can use the following measures to meet your requirement.
Measure 1:=SUMX(VALUES(Sell_to_Country),CALCULATE(MAX(Evaluation[PSalesAmt])))
Measure 2 = IF (
ISFILTERED ( 'Evaluation'[Sell-to Country Code] )
|| ISFILTERED ( 'Evaluation'[Sell-to Customer Name] ),
CALCULATE ( AVERAGE ( Evaluation[PSalesAmt] ) ),
MAXX (
GROUPBY (
ALLSELECTED ( 'Calendar' ),
'Calendar'[Year],
'Calendar'[Week of Year]
),
CALCULATE ( AVERAGE ( Evaluation[PSalesAvgAmt] ) )
)
)
Then We can use the two measures to replace [PSalesAmt] and [PSalesAvgAmt], the result like this,
If you have any other questions, please kindly ask here and we will try to resolve it.
BTW, excel file as attached.
Best regards,
Dear @v-lid-msft ,
It's awesome and working beautiful. I was spend almost a week to get correct figure but no way. May i ask some question? Is it possible to get same figure without adding Lookup column into "Evaluation" table. It mean we directly take the value from "PlanSales" table and make it measure. I worry about the performance if we add lookup column into "Eveluation". Actually, my table has 1,048,576 rows.
Sorry for my cazy question.
Thank you so much for excel attach.
Regards,
User | Count |
---|---|
141 | |
113 | |
104 | |
78 | |
64 |
User | Count |
---|---|
136 | |
125 | |
107 | |
70 | |
61 |