Forum Discussion
Power Bi measures as rows
Hi All,
I have created some measures in PowerBI as per the business requirement
but i can display it as different tables like below as example:
| Sales: | ||
| Feb Sales | March Sales | Percentage diff
|
| 1.5M | 1.8M | Some value |
| Profit: | ||
| Feb Profit | March Profit | Percentage diff |
| 1.5 M | 2.5M | some value |
| Loss: | ||
| Feb Loss | March Loss | Percentage diff |
| 500k | 200k | some value |
I have created sales table chart from content table in powerbi with column content_sales, profit table chart from content table with content_profit and same for loss table chart
and date is also considered from same content table
I will include dax formula which I used for getting those measures
Feb sales = Feb Like = VAR previous_month = EOMONTH(TODAY(),-2)
RETURN
CALCULATE(
DISTINCTCOUNT('Content'[content_sales]),
FILTER(
'Fact Content',
'Content'[date] >= DATE(year(previous_month), month(previous_month), 1)
&& 'Content'[date] <= previous_month
)
)
Like this I achieved Feb profit and feb loss and same as for march month sales, profit and loss
But the business want as below:
| Function | Feb | March | Percentage diff |
| Sales | 1.5M | 1.8M | some value |
| Profit | 1.5M | 2.5M | some value |
| Loss | 500k | 200k | some value |
How can I achieve this please help me out...
Thanks in advance
2 Replies
- AnonymousNot applicable
Hi Anonymous ,
I'm not clear about your requirement, could you please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
- AnonymousNot applicable
Hi,
Okay.
I have table in frontend fields section as below:
and like this sum of loss and sum of profit also
In backend the table is likeI have given an example from excel
I have written logic for sales for previous month and last before month and average sales percentage for last two months based on date field,
Same logics for profit and loss alsoI’m able to show prev month sales, before prev month sales and avg sales percentage in one table chart
prev month profit, before prev month profit and avg profit percentage in one table chart
and for loss in another table chart
Like below
The below is the DAX formula I used to get Prev Month and Bef Prev Month Sales
Prev Month Sales = VAR previous_month = EOMONTH(TODAY(),-1)
RETURN
CALCULATE(
DISTINCTCOUNT('Content'[Sales]),
FILTER(
'Content',
'Content'[date] >= DATE(year(previous_month), month(previous_month), 1)
&& 'Content'[date] <= previous_month
)
)
Bef Prev Month Sales = VAR previous_month = EOMONTH(TODAY(),-2)
RETURN
CALCULATE(
DISTINCTCOUNT('Content'[Sales]),
FILTER(
'Content',
'Content'[date] >= DATE(year(previous_month), month(previous_month), 1)
&& 'Content'[date] <= previous_month
)
)
For Avg % Difference:Sales% = VAR Difference = 'Content'[Prev Month Sales] - 'Content'[Bef Prev Month Sales Sales] RETURN DIVIDE(Difference, 'Content'[Bef Prev Month Sales]) * 100
Like Same I did for Profit and Loss, in DAX
Same for Profit and loss in different table charts
But I want to show all of them in one table chart only, like below as:I want to show Sales, Profit, Loss in as a different rows in Function column,
For Prev Month , Bef Prev month and Avg % Difference columns, I have to show respective sales, profit and loss values in respective rows
Please give solutionThanks in advance