Power BI Categories and Subcategories - powerbi

I have 3 columns in Power BI - Main categories of Costs, and Subcategories of Costs and Values. I would like the preview to be in the same row, as shown in the second table.
This is the table I have.
Category
Subcategory
Values
Acqusition Costs
Brokerage Commissions
9000
Acqusition Costs
Other Commissions
3000
Maintenance Costs
Hardware Maintenance
5000
Maintenance Costs
Software Maintenance
5000
And this is the table I need to show in Power BI
Costs
Value
Acqusition Costs
12000
*Brokerage Commissions
*9000
*Other Commissions
*3000
Maintenance Costs
10000
*Hardware Maintenance
*5000
*Software Maintenance
*5000
Thank you in advance.

Are you trying to make a table? Or is this a visualization for a PowerBI a report?
You wouldn't make an actual table object in your PowerBI Model this way. Your first table can be abstracted upon by either DAX or the available PowerBI visuals to get the result you want.
For example, using your initial dataset in the model:
This can be abstracted with PowerBI's Matrix visual to get your desired output:
Notice how you can stack categorical columns within the 'Rows' visualization section. This provides the effect of a hierarchy between your categories.
Hope this helps.

Related

compare a measure to a value in a column

Power BI noob here, still thinking like a SQL coder, so please be patient.
How can I use the user name of the person running the report to filter the report?
As a convenience for my users, I want to provide a way for them to automatically filter to only see data related to their office or region. I have a Person table that includes details like their office location. If I can filter that based on the user name of the person running the report, and join it to the rest of the data, that would work.
Unfortunately, I don't see a way to get the user name in M.
Using the USERNAME() function in DAX, I don't see a way to compare this with individual values in a column. I get an error about being unable to compare a measure to multiple values.
It seems this would be a common request, so I'm sure somebody has solved this problem. But I haven't yet found the solution.
Use a RLS in your model. You can use function USERNAME(),USEROBJECTID (), USERPRINCIPALNAME (); The last one is useful if you have table with users and their email.
https://learn.microsoft.com/en-us/power-bi/admin/service-admin-rls
check also this GuyInCube video:
https://www.youtube.com/watch?v=MxU_FYSSnYU
First, be aware of the differences between USERNAME() and USERPRINCIPALNAME(). Most likely you will want to use the later one.
You can't use neither of these in M. Imagine your model is importing the data. The M code is executed once in the context of one user, then each other user accessing the published report will reuse the already loaded and calculated model. And of course, these are DAX functions, not M.
So in DAX you can use these to compare their values to columns from your model. You didn't gave any information about your model, but lets say there is a table Sales with columns Customer and Amount:
Customer
Amount
Bill Gates#Microsoft.local
100
Steve Ballmer#Microsoft.local
110
In this case, you can write a measure like this:
My Sales = CALCULATE(SUM('Sales'[Amount]), 'Sales'[Client] = USERPRINCIPALNAME())
When Bill Gates opens the report, he will see sales amount of 100, while if Steve Ballmer opens it he will see 110.
For diagnostic purpose, you can make a measure like this and show it somewhere in your report:
Who am I = USERPRINCIPALNAME()
If your goal is to build dynamic Row-Level Security within Power BI, it has some functionality which might help you, so take a look at these articles:
Row-level security (RLS) with Power BI
Restrict data access with row-level security (RLS) for Power BI Desktop
Row-level security (RLS) guidance in Power BI Desktop
Dynamic Row Level Security with Profiles and Users in Power BI : Many-to-Many Relationship

Filtering sales as per the top 10 customers in Power BI

I want to filter the monthly sales as per the top 10 customers' sales in power bi. Can any one help me with that DAX.
I suggest that you look at the RANKX function, I'm sure this will do what you need, have a look over at SQLBI I can't offer anything more specific as your request is pretty general. Post a more specific question if you run into trouble!

How to display hierarchical data with slicer Power BI?

I have a data table:
I need to perform KPI for Organization, Team and every employee, KPI of Team is the data of the employees in the team, KPI of Organization is the data of all employees. The result I want is a diagram showing 3 KPIs of the selected object.
To do this, I created a Hierachy Slicer to filter the objects that need to be calculated:
My slicer works fine if I create Measure to calculate each KPI value but it doesn't work when I create a new Data table to store KPI values, I don't know where the problem is, please help me.

Power BI - Merging multiple customer tables

Connection Type: Direct Query to multiple sources so limited DAX available especially in Power Query load.
Data Model Query: The Data model is not a perfect star schema but there is an attempt to separate tables into business processes and lookup tables. There are probably a few issues to discuss the current data model. I only have 1 question at this time.
My current goal is to generate a single summarised customer table to replace the current two tables that have some measure I need like the number of app customers, a number of total customers, date customer first accessed app etc.
So I cannot merge the 2 customer tables and add calculated columns and measures at the import stage as power bi does not support or allow it and sql is out as I am using direct query. My plan is to create a summarised customer table using DAX summarise function on front end visual page, that has only the app customers and then measures like the total number of customers etc. Is this best practice or is there a better way of approaching this? Understand you would ideally do in sql, or power query but in these circumstances, I think this is the best way but wanted a second view.
Is there a reason to use Direct Query over Import? If you are in Import mode, you can easily Append the two client tables together in PowerQuery.
Treb Gatte, Power BI MVP

Power BI Measure filtering with ONLY date

I am working on a power bi report to show the Servers' performance against the Restaurant's performance.
I have two main tables: feedback and server
feedback and server tables have cross filter direction of "both"
I have a chart for the names and their served counts and the user can click the servers and the report should change appropriately.
I have 2 main measures: performance indicator for the restaurant and server
I would like to create a Restaurant Performance measure that is ONLY filtered by the time slicer(Timeline), AND does not drill down when I click the name of the servers. I have the following code but it seems my number is off somehow. Any ideas?
_MEASURE_CSI_TABLETALK = CALCULATE(SUMX(Feedback, [TotalFeedback] * [AverageRating]), ALLEXCEPT(servers, servers[AverageRating])) / CALCULATE(SUM(Feedback[TotalFeedback]), ALLEXCEPT(servers, servers[ServedCount]))
One solution to your problem is to handle the interactions between visuals in Report view.
Click the Edit interactions button in the Format page of the ribbon. Now when you select the chart that has the names of the servers, you can change the way that that chart filters all other visualisations on the same page, for the visual which displays your Restaurant Performance measure, click 'None':