Forum Discussion
Calculated Row using Power BI DAX
I have 3 related tables: Actual PL, Item Group and Calendar
My objective is to insert calculated row in Matrix Table
Below measure was created in Actual PL table
output:
this DAX is working in my other project. can't find reason why it's not working in this project
please help.
- Anonymous4 years ago
Hi Dulay
I have checked your code by my sample. I think the logic of your code is correct. There may be something wrong in your filter or calculation. Here I will give you some suggestions.
My sample is as below.
Actual PL:
Item Group
Calendar table is a calculate table.
Calendar = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]),"QTR","Qtr"&" "&QUARTER([Date]))Relationship:
I think list part in Var in your code is useless, we can remove it and the code will still work successfully.
My result:
1. Please check your Matric, you should use [Item Group] from "Item Group" table.
2. Please check your code and make sure values in "Switch" function like "EBITDA" are correct. If they are wrong, your measure will return blank.
3. Check the your calculate by "EBITDA", maybe REVENUE - EXPENSE are the same the return to blank.
You can download my sample to get more details.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- AlexisOlsonSuper User
Can you confirm that EBITDA is a row in the column 'Item Group'[Item Group]?
- DulayNew Member
Yes. These are the rows in the Item Group table
- AnonymousNot applicable
Hi Dulay
I have checked your code by my sample. I think the logic of your code is correct. There may be something wrong in your filter or calculation. Here I will give you some suggestions.
My sample is as below.
Actual PL:
Item Group
Calendar table is a calculate table.
Calendar = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]),"QTR","Qtr"&" "&QUARTER([Date]))Relationship:
I think list part in Var in your code is useless, we can remove it and the code will still work successfully.
My result:
1. Please check your Matric, you should use [Item Group] from "Item Group" table.
2. Please check your code and make sure values in "Switch" function like "EBITDA" are correct. If they are wrong, your measure will return blank.
3. Check the your calculate by "EBITDA", maybe REVENUE - EXPENSE are the same the return to blank.
You can download my sample to get more details.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- DulayNew Member
Thanks very much Anonymous
Was able to solve this by removing the SORTing of Item Group using SORT Column. Both are in Item Group table.
Your solution is great also.