The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello, I have loaded in a table (visual element within power bi canvas) a list of the 8 provinces of Andalusia, and I need to apply a calculation depending on the city that appears, for example if the city is Malaga I need to divide number of sales by amount sold and multiply it by a certain percentage (let's say that for Malaga it is (3%). But if it appears in the Cadiz table I need you to do the same by multiplying it by 4%.
I tried to use the function as follows... if(MAX('Mu Papel Id Caras ADHOC'[City] = "MALAGA"), (nunSales/sales)*3% but indicates the following error "the Max function only accepts a column reference as an argument"
Greetings and thanks in advance
Solved! Go to Solution.
Hi @Syndicate_Admin ,
For the created measure, an aggregate value needs to be nested in the field, indicating the current row. The reference is as follows.
Product =
SWITCH (
TRUE (),
MAX ( 'Table'[Ciudad] ) = "MALAGA",
( 400 / 5 ) * 0.03,
BLANK ()
)
If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Syndicate_Admin ,
For the created measure, an aggregate value needs to be nested in the field, indicating the current row. The reference is as follows.
Product =
SWITCH (
TRUE (),
MAX ( 'Table'[Ciudad] ) = "MALAGA",
( 400 / 5 ) * 0.03,
BLANK ()
)
If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I have tried to do a test and it had never happened to me, the table or the column does not recognize me and I have looked at the table and it is well written, do you know why this can happen?
I pass the screen print of both the measurement and the table with that column
I would try a switch statement:
SWITCH(
TRUE(),
Mu Papel Id Caras ADHOC'[City] = "MALAGA", (nunSales/sales)*3%,
Mu Papel Id Caras ADHOC'[City] = "City 2" , Calculation 2,
etc.