How do I do addition by row in Power BI DAX? - powerbi

I would like to add Source as per shopping, booking, campaign, and web in Power BI DAX. For example, there are 3 shopping, 2 booking, 3 campaign and 2 web.
Source
Shopping_HVAL
Shopping_MVAL
Shopping_LVAL
Booking_HVAL
Booking_LVAL
Campaign_HVAL
Campaign_MVAL
Campaign_LVAL
Web_HVAL
Web_MVAL

Related

SSAS/ PowerBi / DAX - How to combine multiplie colunms in one

I am using Power Bi with SSAS Tubular Model.
I have a table that causes duplication due to multiple managers on a project.
Projekt Manager Revenue
Car-Sales Bob 200k
Car-Sales Chris 200k
Car-Sales Tina 200k
I want to combine these Manager entries to one entry with commas.
Projekt Manager Revenue
Car-Sales Bob,Chris,Tina 200k
How do I write this in DAX?
This should be done upstream in your data shaping stage but if you're stuck with DAX, then create a new table as follows:
Table 2 = ADDCOLUMNS( SUMMARIZE('Table', 'Table'[Projekt], 'Table'[Revenue]), "Manager", CONCATENATEX('Table', 'Table'[Manager], ","))

All rows and total of the rows showing same values in power BI

I am trying to show "Some Column Name" against "Total Amount" in Power BI.
I am expecting the following results:
But instead it's showing me the following results:
The current data type is "fixed decimal number" I tried changing it to "Decimal number" or "Whole Number" but it did not work.
Any suggestions?
The reason why you have a single repeating value is because you did not create a relationship in powerbi model. If for example you have two tables Sales and Staff and you want to sum all staffs sales.
if no relationship created between table in power BI
The output will look like this
However when a relationship is created between the tables
The output will be correct
This is almost certainly the result of a many-to-many relationship in Power BI. In Power BI if there are connections between two (or more) tables that evaluates to a many-to-many relationship then Power BI is unable to make a distinction between any two rows and instead will project the same value for any given row placed in a visual.
Here's an easy way to visualize this:
Table 1 Table 2
Product | ID AmountSold | ID
Widget 1 10 1
Smidget 1 20 2
Gidget 2 5 1
When you join these Power BI can't tell the difference in Sales between Widget and Smidget because they have the same ID. As far as Power BI knows Widget could have sold 0 and Smidget sold a total 15, or Widget sold a total 5 and Smidget sold a total 10, etc.
As a result of this many-to-many relationship Power BI panics and evaluates them to be the same result because it can't determine what is right. Widget and Smidget both sold a total of 15:
Visual
Product | AmountSold
Widget 15
Smidget 15
Gidget 20
You're experiencing the same issue in your data model, although it is undoubtedly a much more complex relationship than the one I just laid out. You need to go back and determine what table(s) are experiencing a many-to-many relationship and fix the issue. Based on the information you've provided it can't be done from here.

How to show last six months data(one row for each month) in MDX query based on selected month filter in Power BI report?

I have created a cube with one fact table and 5 dimension which includes one Date dimension. Hierarchy of date dimension is Year -> Quater -> Month. Here I want to select the last six months data from selected month using mdx query. The output should be Month (Row Level) and Measures on Column level.
Thought of creating a dynamic named set but power BI doesn't consume named sets.
Can anyone please suggest a way to do it in MDX either using a disconnected date dimension or any idea in Power BI?
Take a look at the sample below
select
[Measures].[Internet Sales Amount]
on 0
,
[Date].[Calendar].[Month].&[2012]&[4].lag(6):
[Date].[Calendar].[Month].&[2012]&[4]
on 1
from
[Adventure Works]
Result

How to display subgroup totals in a table visual in Power BI?

I need to display subgroup totals in a table visual in Power BI. However, Power BI is showing me incorrect totals. How do I create a measure to show this?
My current table visual is:
My table relationships are:
What I need is:
SiteName LiftName Amount
Site 1 Lift 1 668.00
Site 1 Lift 2 668.00
Site 2 Lift 3 604.00
Site 3 Lift 4 9.54
Site 4 Lift 6 9622.50
Site 4 Lift 8 9622.50
Site 4 Lift 9 9622.50
I have tried adding an inactive relationship and using that with a USERELATIONSHIP function, but it gives me the same as what I have already:
SiteAmount = calculate(sum(Sales[Amount]),USERELATIONSHIP(Sales[SiteID],Sites[SiteID]))
Is there any way to get this table to display as needed? I cannot amend the relationships in the model to link Sales table with Sites table directly. See below PBIX if needed:
https://1drv.ms/u/s!AuiIgc_S9J5JhbYbCO2jbeQPfpzmXw
Cheers
What you want, it seems to me, is the sum of [Amount] without any filtering except for Site. DAX provides the ALLEXCEPT function to do this kind of filtering.
Unfortunately, the field that whose influence we're trying to ignore is part of the relationship to the tables in the visual. So we get some weirdness and I think it's unavoidable. We can ask DAX to hide those rows as a second step.
SiteAmount =
Var Amount = CALCULATE(
SUM(Sales[Amount])
, ALLEXCEPT(Sales,Sites[SiteName]
))
RETURN IF(ISBLANK(SUM(Sales[Amount])),BLANK(), Amount)

Date Column in Power BI spiting into 4 columns

I'm using Power BI, pulling data from a SQL server, but for a column containing date, it keeps splitting into 4 other columns when I try and show it in a table:
Year | Quarter | Month | Day
Has anyone had this issue before?
Note: Under modeling, when selecting that field I did try placing Data Type as Date. No change.
This is because Power BI made a date hierarchy from this field. If you do not want this, right click it in the designer and uncheck Date hierarchy from the menu: