My current mesure for "Orders" elects the MAX of the MAX of two number values.
Range MAX Orders = MAXX(
{
Max(Ziele[ScopeOrd]),
MAX(Ist[Orders])
},
[Value]
)
The Result is correct = 35
My problem is, that for my "Company" mesure I have the string Names of the companies and the numbers for my scope.
So I guess that I need to create a count mesure first, but it should still be in the context of the countries. Or is it possible to put all in one?
I have tried:
Range MAX Orders = MAXX(
{
Max(Ziele[ScopeComp]),
MAX(COUNT(Ist[Company]))
},
[Value]
)
Unfortunatly that results in an error:
The MAX function only accepts a column reference as an argument.
Please let me know how to solve it best.
Here is some example data.
Table Ist:
Company|ISO2
Acme Corporation|US
Globex Corporation|US
Soylent Corp|DE
Initech|DE
Umbrella Corporation|IT
Hooli|US
Vehement Capital Partners|US
Table Ziele:
ScopeComp|ISO2
2|US
3|DE
2|IT
The Result for the exampe data should be = 4
Since there is a COUNT of 4 companies in the US and this is greater then the number 3 MAX of the ScopeComp.
Try this one:
Range MAX Orders =
VAR Tbl = MAXX(ADDCOLUMNS(
VALUES(Ist[ISO2]),
"TCount",CALCULATE(COUNT(Ist[ISO2]))
),[TCount])
VAR Tbl2 = MAX(Ziele[ScopeComp])
RETURN
MAXX(
{Tbl,Tbl2},[Value])
If we test it on a visual card,
Related
I have a summary table in Power BI which shows how many days it takes for leads to convert to a sale. It has 2 columns, sum_convert (the amount of days in between lead creation date and converted date) and count_lead (the count of leads that have taken that amount of days to convert), both are numeric values. Here is an example of the data:
What I want, is a column next to count_lead that shows the running percentage total in the specific ascending order of sum_convert. Currently I've created a measure called lead_count which is the sum of count_lead. Then I've attempted to create the cumulative total with the following measure:
Cum_Lead = calculate([lead_count], FILTER(ALL(Convert_Count_Summary[Sum_Convert]), SUM(Convert_Count_Summary[count_lead]) <= [lead_count]))
This creates a cumulative total, but not in the specific sum_convert order, it's in the order of largest volume for count_lead. Any idea what I need to change so that it's in the order of sum_convert?
You could do this in Power Query using M:
= Table.AddColumn(#"Previous Step", "Cumulative_Count_PQ", each List.Sum(List.FirstN(#"Previous Step"[count_lead],_[sum_convert]+1)), type number)
Or as a calculated column using DAX:
Cumulative Count DAX =
CALCULATE (
SUM ( Convert_Count_Summary[count_lead] ),
ALL ( Convert_Count_Summary ),
Convert_Count_Summary[sum_convert] <= EARLIER ( Convert_Count_Summary[sum_convert] )
)
Edit:
Cumulative percentages in Power Query:
= Table.AddColumn(#"Previous Step", "Cumulative_Count_Percent_PQ", each List.Sum(List.FirstN(#"Previous Step"[count_lead],_[sum_convert]+1)) / List.Sum(#"Previous Step"[count_lead]), Percentage.Type)
Cumulative percentages calculated column in DAX:
Cumulative Count % DAX =
VAR _Numerator =
CALCULATE (
SUM ( Convert_Count_Summary[count_lead] ),
ALL ( Convert_Count_Summary ),
Convert_Count_Summary[sum_convert] <= EARLIER ( Convert_Count_Summary[sum_convert] )
)
VAR _Divisor =
SUM ( Convert_Count_Summary[count_lead] )
RETURN
DIVIDE (
_Numerator,
_Divisor
)
I have Data like this and I want to create a matrix visual. Since I need the Amount and Percentage in one column inside the matrix, I have created the following structured table in Power BI:
Description
Value
Sales Amount
50000
Sales Percentage
12%
Sales Amount
25000
Sales Percentage
25%
Sales Amount
75000
Sales Percentage
64%
Since it's not possible to store different format types in a single column in Power BI the percentage is stored as decimals and I created a measure to change the format based on the description column with the following code:
Value_formated =
VAR Val = SUM ( Table[Value] )
RETURN
SWITCH (
SELECTEDVALUE ( 'Table'[Description] ),
"Sales Amount", FORMAT ( Val, "0" ),
"Sales Percentage", FORMAT ( Val, "0.00%" ))
My question is how am I able to create a conditional formating to change the underlying color based on the percentage Value? Like for example if the percentage is negative, the percentage field should be red and if positive green. But since percentage is mixed with total number, how can I only filter the percentages? I have tried the following guide: https://xyloslearning.com/en/power-bi-using-a-measure-to-set-up-conditional-formatting/ but I couldn't select the coloring measure maybe because there are two different formats? Can anybody help me?
Thanks!
Create a format measure as follows:
Format =
VAR v = MIN ( 'Table'[Value] )
VAR d = MIN ( 'Table'[Description] )
RETURN
SWITCH(TRUE(),
d = "Sales Percentage" && v < 0, 0,
d = "Sales Percentage" && v >= 0, 1,
2)
Apply conditional formatting as follows:
Does anyone know how you can add a power BI slicer so that the values in a matrix go from thousands to millions based on the selection of another slicer?
So if I select all business units then the sum of all values are returned in millions, else if i select one business unit, all values are returned in thousands?
Sorry, I have no DAX code.
Thanks.
This is covered nicely here:
https://www.daxpatterns.com/parameter-table/
(The DAX below is copied from that page.)
Create a new parameter table to use in a slicer.
Scale =
DATATABLE (
"Scale", STRING,
"Denominator", INTEGER,
{
{ "Units", 1 },
{ "Thousands", 1000 },
{ "Millions", 1000000 }
}
)
Incorporate the denominator into your measure(s). For example,
Sales Amount :=
VAR RealValue =
SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )
VAR Denominator =
SELECTEDVALUE ( Scale[Denominator], 1 )
VAR Result =
DIVIDE ( RealValue, Denominator )
RETURN
Result
I'm a relative neophyte with DAX so bear with me. In the simplest terms, I want to double the measure amount for all regions that are not Europe, then sum the result. Here is some example DAX:
DEFINE
measure Fact[test] = CALCULATE (IF(SELECTEDVALUE('Dim'[Region]) = "Europe", Fact[Revenue],Fact[Revenue] * 2))
EVALUATE(
SUMMARIZECOLUMNS(
ROLLUPADDISSUBTOTAL('Dim'[Region], "RegionSubtotal"),
"Original Measure", Fact[Revenue],
"New Measure", Fact[test]
)
)
Region
RegionSubtotal
Original Measure
New Measure
Asia
False
200
400
Americas
False
500
1000
Europe
False
300
300
True
1000
2000
I'm trying to get (400+1000+300) = 1700 for the second column instead of 2000. Any ideas?
For the subtotal row, the selected value is not "Europe" so it's doubling the value.
To fix this, you want to iterate over the regions in your measure. Something like this:
test =
SUMX (
VALUES ( 'Dim'[Region] ),
IF (
'Dim'[Region] = "Europe",
[Revenue],
[Revenue] * 2
)
)
An other alternative would be to create a calculated column wherein , in case if region<>Europe, then amount* 2 else amount.
Then take the sum of the calculated column , but this would be like having an additional data .
I have a table which looks like this:
I need to calculate sum of all numbers in column :ADD , IF the number in column CHANGE is 0 AND column DELETE is 0.
The actual data looks like below. Its same as above. The items with red backets should be filtered out because there are values against delete and change for each unique number in MEMO column.
Create a Measure as below to Exclude records from the list-
exclude =
VAR current_row_tsframe_account = MIN(your_table_name[TSframe_Account])
VAR current_row_tsframe_memo = MIN(your_table_name[TSframe_Memo])
VAR find_delete_change_for_memo =
CALCULATE(
COUNT(your_table_name[TSframe_Memo]),
FILTER(
ALL(your_table_name),
your_table_name[TSframe_Memo] = current_row_tsframe_memo
&& your_table_name[TSframe_Account] = current_row_tsframe_account
&& your_table_name[TSframe_Mode] IN {"CHANGE","DELETE"}
)
)
RETURN
IF(
find_delete_change_for_memo > 0,
"Yes",
"No"
)
The above Measure will return Yes/No per row. You can now Apply visual/page level filter so that records only show where measure Exclude = No. Now this below measure will show your expected value-
total = SUM(your_table_name[TSframe_Memo])