Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi Everyone, I am working on Migrating a Tableau Project to Power BI
In Tableau there is a fixed Lod name currentpremium
{Fixed[Country],[ClientID]:Min([Premium])}
for this i writo below dax
CALCULATE(
MIN('Table'[Premium]),
ALLEXCEPT(
'Table',
'YourTable'[Country],
'YourTable'[ClientID],
))
now tableau is using a new lod on top of currentpremium
Calc__Q2=
{Fixed[Country],[Clientid]:Percentile([currentpremium],0.5)}
How can i replicate this in power bi.
i am trying to use allexcept but inside percentile i am not able to use measure name
and while placing this calculation in tableau, it is performing average
so my power bi should also perform average in calculation
@bhanu_gautam - Thanks for Providing the solution but i am not getting the correct result
I am working on a calculation that involves computing the average of percentiles based on grouped data. I am able to get the correct result (16948) by creating separate DAX-calculated tables, but I am unable to achieve the same result using measures.
Here’s what I did that worked:
I created a table calc_currentPremium using the following DAX: Calc_currenrrate =
SUMMARIZE(
'Plan',
'Plan'[Country],
'Plan'[ClientID],
'Plan'[Producttype],
'Plan'[PlanDesignYear],
"mincurrentPremium", MIN('Plan'[Currentrate_premium])
)
On top of this, I created another table Q2 to calculate the median:
Q2 =
SUMMARIZE(
Calc_currenrrate,
Calc_currenrrate[Country],
Calc_currenrrate[Producttype],
Calc_currenrrate[PlanDesignYear],
"Median", PERCENTILE.INC(Calc_currenrrate[mincurrentPremium], 0.5)
)
Finally, I created a measure to calculate the average of medians:
AvergareQ2 = AVERAGE(Q2[Median])
This approach gives me the correct result.
However, when I try to implement the same logic entirely as measures without creating intermediate tables, the result is incorrect
MinCurrentRate =
CALCULATE(
MIN('Plan'[Currentrate_premium]),
ALLEXCEPT(
'Plan',
'Plan'[Country],
'Plan'[ClientID],
'Plan'[Producttype],
YEAR('Plan'[PlanDesignEffectiveDate])
)
)
MedianCurrentRate =
PERCENTILEX.INC(
SUMMARIZE(
'Plan',
'Plan'[Country],
'Plan'[Producttype],
YEAR('Plan'[PlanDesignEffectiveDate]),
"MinRate", [MinCurrentRate]
),
[MinRate],
0.5
)
AverageMedianRate =
AVERAGEX(
SUMMARIZE(
'Plan',
'Plan'[Country],
'Plan'[Producttype],
YEAR('Plan'[PlanDesignEffectiveDate]),
"Median", [MedianCurrentRate]
),
[Median]
)
Hi @kapildua16 ,
Based on your description, the fact that the same logic works for the calculation table but not for the MEASURE may be due to the different contexts they are applied to. In tables or matrices, the columns used in the measure that are missing from the visualization may also result in a different context. If you want more accurate help, you can provide full example data or pbix files and expected results so we can help you faster. Please hide sensitive information in advance.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
@kapildua16 , First create a measure for
currentpremium =
CALCULATE(
MIN('Table'[Premium]),
ALLEXCEPT('Table', 'Table'[Country], 'Table'[ClientID])
)
create a measure for Calc__Q2 which calculates the 50th percentile (median) of currentpremium
Calc__Q2 =
CALCULATE(
PERCENTILEX.INC(
SUMMARIZE(
'Table',
'Table'[Country],
'Table'[ClientID],
"currentpremium", [currentpremium]
),
[currentpremium],
0.5
),
ALLEXCEPT('Table', 'Table'[Country], 'Table'[ClientID])
)
if you need to perform an average calculation on top of Calc__Q2, you can create another measure:
Average_Calc__Q2 =
AVERAGEX(
SUMMARIZE(
'Table',
'Table'[Country],
'Table'[ClientID],
"Calc__Q2", [Calc__Q2]
),
[Calc__Q2]
)
Proud to be a Super User! |
|
User | Count |
---|---|
84 | |
73 | |
67 | |
42 | |
35 |
User | Count |
---|---|
109 | |
56 | |
52 | |
45 | |
43 |