Power BI: Multiply Grouping by Related Parameter - powerbi

I'm fairly new to Power BI, so may be overlooking something basic here.
I have a Column which contains a banding number (1 to 3), depending on a customer's total spend.
Band 1: 0 - 500
Band 2: 501 - 1000
Band 3: 1001+
I have created 3 Parameters on my report (Parameter 1, 2 and 3).
Each parameter allows for a decimal range between 5 and 35 with increments of 2.5
This parameter will represent the percentage of the income that is earned by a consultant.
I'm trying to create a measure that multiplies the Income by the respective Parameter. Allowing users to adjust the percentage earning dynamically when viewing the report.
Below is an example of the table.
Table Name: Receipts
Policy Number
Client Name
Band
Income
SA1
Ray Mann
3
800
SA2
Ray Mann
3
900
SA3
Mary Yu
2
600
SA4
Sam Fry
1
20
SA5
Sam Fry
1
50
I'm a little lost on this one.
As a calculated columns I would do a simple SWITCH statement, however as it's not a measure it will not adjust dynamically as the parameter slider is changed.
Your help is greatly appreciated.
Kind regards,
Morallis

Let's say there are three what-if parameters, named Parameter1, Parameter2 and Parameter3, and your table is named Table. We can create a measure, which first will use SUMMARIZE to summarize the data calculating the total income per band:
SUMMARIZE('Table', 'Table'[Band], "Income", SUM('Table'[Income]))
Then will use SUMX to calculate the multiplied income:
Multiplied Income =
SUMX(
SUMMARIZE('Table', 'Table'[Band], "Income", SUM('Table'[Income])),
[Income] * SWITCH([Band],
1, Parameter1[Parameter1 Value],
2, Parameter2[Parameter2 Value],
3, Parameter3[Parameter3 Value],
1)
)
The result will be as follows:

Related

How to calculate ratio for every row in power bi?

Could someone please guide me through this situation?
I have a need to compute for every row the ratio between, volume of the row and sum of volumes of rows of a given transport type.
But after calculating this calculated column, I would like to use it in a table visualization, and be affected by any slicer of it...
Was I clear?
Here follows the example of rows:
Delivery Method Order Nr VOLUME Ratio
Air 50102258 9 33%
Sea 50091716 50 52%
Sea 50092425 47 48%
Air 50102257 18 67%
Here's your measure (a calculated column doesn't work here since you have to aggregate per method):
% Volume =
DIVIDE(
SUM('Table'[VOLUME]),
CALCULATE(
SUM('Table'[VOLUME]),
ALLEXCEPT('Table','Table'[Delivery Method])
)
)
If the answer was useful please accept it and give it an upvote.

Is there a way to filter a table based on criteria from another table in Power BI using DAX?

So, I have two tables, Scores and Accounts.
ID
Score
1
120
2
150
3
100
ID
Account
1
Account 1
2
Account 2
3
Account 3
I also have 4 measures that calculate the quartile percentile for all of the scores in the Scores table. I was wondering if it was possible to have a measure that concatenates the accounts into one line if their score is, for example, greater than the Quartile 1 measure. For example, if quartile 1 is 110, then I want a measure that would give me "Account 1, Account 2". Is this possible?
I managed to get your result by implementing the following measure, assuming you have a relationship between the two tables.
Accounts GT Q1 =
CONCATENATEX(
FILTER(
Scores,
Scores[Scores] > [Quartile 1]
),
RELATED( Accounts[Account] ),
", "
)
Output
There may be a simpler way. Let me know if that worked.

Calculate total variance in power bi with dax

I have 3 measures:
1) total_trx = SUM(mytable[trx])
2) trx_prev_month = CALCULATE([total_trx], DATEADD(calendar[date], -1,MONTH))
3) monthly_var = DIVIDE([total_trx],[trx_prev_month])-1
If I add a waterfall viz, x-axis with month, it gives me the % of monthly variation and a TOTAL bar at the end that sums all the variations.
I need to reproduce that total number in order to show a KPI as in "so far, we've increased ...%", changing when using a date slicer.
Seems like sum(monthly_var) is not allowed.
Any ideas?
Thank you very much.
Edit1: sample with date filter = Last 4 months
Jul 100 0%
Aug 110 10%
Sep 90 -20%
Oct 80 -10%
Total: -20% <- need a dax to calculate this number and show just -20%
Then if I change the filter to, for example LAST 6 MONTHS, I need to calculate it up to May
In order to get the desired result we will use an intermediate table in our query that will summarize the results by months:
use this code and replace calendar[Year Month] with your Year month column :
SUMX(
SUMMARIZECOLUMNS(calendar[Year Month],"Monthly_int_var",[monthly_var]),
[Monthly_int_var]
)

Visualization Issues using Running Total on an Appended Query

Using PowerBI linked to two separate Access Databases.
I have two datasets containing cost estimates. The cost estimates in Dataset 1 run through 2054; the cost estimates in Dataset 2 run through 2074. I used the Append function to join the two tables together and used the Quick Measure for Running Total to create values for cumulative cost by year. I charted this measure and noticed a significant decrease between 2054 and 2055 and was able to determine that the decrease is the cumulative value for Dataset 1. Does anybody know any ways to fix this?
Roughly explained:
Dataset 1 through 2054 totals to 4.5M.
Dataset 2 through 2054 totals to 3M
Dataset 2 through 2055 totals to 3.25M
Appended Dataset through 2054 totals to 7.5M
Appended Dataset through 2055 totals 3.25M instead of the expected 7.75M
I think the issue might be caused by Dataset 1 not having a value for 2055 or after, but I'm not sure how to resolve this issue.
The measure I'm using is:
Cumulative Cost =
CALCULATE(
SUM('AppendedQuery'[Value]),
FILTER(
ALLSELECTED('AppendedQuery'[Year]),
ISONORAFTER('AppendedQuery'[Year], MAX('AppendedQuery'[Year]), DESC)
)
)
ETA: Picture to explain
Here is your Dataset 1-
Here is your Dataset 2-
Here is your final Dataset after appending Dataset 1 & 2
And finally, here is the output when you are adding column Year and Cumulative Cost to a table visual. As standard PBI behavior, this is just grouping data using column Year and and applying SUM to the column Cumulative Cost.
The calculations are simple-
2051 > 1 + 1 = 2
2052 > 2 + 2 = 4
2053 > 3 + 3 = 6
2054 > 4 + 4 = 8
2055 > 5 = 5
2056 > 6 = 6
=========================
Solution for your case:
I already said in the comments that the solution current data will be not a standard one and will consider fixed $1 per year per department. But if you are happy with this static consideration, you can apply these following steps to achieve your required output-
Step-1 Create a Custom Column as below (Adjust the table name as per yours)-
this_year_spent = IF('Dataset 3'[Cumulative Cost] = BLANK(),0,1)
Step-2 Create the following Measure-
cumulative =
VAR current_year = MIN('Dataset 3'[Year])
RETURN
CALCULATE(
SUM('Dataset 3'[this_year_spent]),
FILTER(
ALL('Dataset 3'),
'Dataset 3'[Year] <= current_year
)
)
Here is the final output-

Power BI Measure to calculate percentage which changes with filters

I want to create a visualisation from a dataset which shows percentages that change accordingly when filters are used.
I have a dataset like the below but with over 1 million rows of data covering 18 months. All the fields are text except Month which is a date and SUMofAPPTS which is numerical.
SUPP GEOG1 MODE STATUS TYPE TIME Month Day SUMofAPPTS
AA 00D Face Att 1 1 Day 2018-06 Sun 12
AA 00D Face Att 1 1 Day 2018-06 Mon 119
AA 00D Face Att 1 4 Unk 2018-06 Tues 98
BB 00D Tel DNA 2 1 Day 2018-06 Weds 98
BB 00D Online DNA 3 1 Day 2018-06 Thurs 126
CC 00D Face DNA 1 2 Day 2018-07 Sun 8
I would like a measure which calculates the percentage of SUMofAPPTS by Day and MODE (and the same but for STATUS, TYPE and TIME) which changes when filters are placed on the other fields.
So I think I need to make this simple calculation (which would work in a column if I just wanted to know the percentage per row of the whole dataset) more dynamic so that it works when I filter the data:
PERCENT = 'dataset'[SUMofAPPTS]/SUM('dataset'[SUMofAPPTS])
The end result will be a stacked bar chart with the following attributes:
Day as the Axis
PERCENT as the Value
MODE, STATUS, TYPE or TIME as the Legend
Ability to filter by one, many or all of the fields except Day and SUMofAPPTS
First, create a measure for aggregating SUMofAPPTS:
Total APPTS = SUM(Data[SUMofAPPTS])
Second, create a measure for the percentage:
APPTS % of Selected
= DIVIDE(
[Total APPTS],
CALCULATE([Total APPTS], ALLSELECTED()))
This measure recalculates [Total APPTS] ignoring all filters except those selected by a user (on slicers etc).
Result:
after selections:
Edit
If you need to breakdown by Day (or any other field), you can re-introduce filters like this:
APPTS % of Selected
= DIVIDE(
[Total APPTS],
CALCULATE([Total APPTS], ALLSELECTED(), VALUES(Data[Day])))