I'm trying to apply this trick from Bas in which he switches between absolute values and % of total : https://www.youtube.com/watch?app=desktop&v=UnG0u8J0pSc
However, this solution doesn't quite work for me for a very good reason : I am not using a measure but a bare column in the context as Y value, thus the SELECTEDMEASURE() cannot work.
Thus my question, how may I use such a lovely trick to print raw value vs % without having a measure in the context please ?
Here is the code :
DIVIDE ( SELECTEDMEASURE(), CALCULATE ( SELECTEDMEASURE(), REMOVEFILTERS('ConsolidatedCapacityPlan'[Project category]) ) )
Here is a summary of my fields :
Thanks in advance for your help,
Nicolas.
No
Calculation groups work with explicit DAX measures. In this example,
Sales is an explicit measure already created in the model. Calculation
groups do not work with implicit DAX measures. For example, in Power
BI implicit measures are created when a user drags columns onto
visuals to view aggregated values, without creating an explicit
measure.
Calculation groups
And creating explicit measures and hiding the source columns is a basic best-practice. For instance Excel also requires explicit DAX measures.
Related
Situation:
My Report calculates the ranking developments of an accounts in one measure:
Class_Evolution = [Class_Minus_0] & " <-- " & [Class_Minus_1]
Combined with data from the source table the measures show good results per datarow.
The results look like:
...
[Class_Minus_0] and [Class_Minus_1] are measures with X-functions themself that result in a ranking (A,B,C,D) depending on slicer selection.
I also have a measure that counts the rows:
Count Values = COUNTROWS(ExhibitorClass)
This works so far.
Problem:
Now I need to crate visuals with the measures I created. But when I put my measures on a visual they just get summed up:
Need:
I need to built the visuals as in the example below but by using my measured instead of columns.
I have build the report without a slicer on fixed data columns with fixed ranking cutoffs and got a nice result:
However I need to be able to calculate the ranking development with the slicer so I need to build everything with measures.
How should I build my measures to get the visuals I need? Please help me.
Thanks to Andrew, I was able to implement the following solution.
I needed a new Table matching the possible results of the measure:
Then with a VAR variable in a DAX measure the matching values could be counted:
Visual Count Class Evolution =
VAR _rank_evolution = SELECTEDVALUE('Class_Evolution'[Class_Evolution])
return sumx('ExhibitorClass_Details', if([Class_Evolution] = _rank_evolution, 1,0))
The variable was populated form my [Class_Evolution] table and if the measure used on my [ExhibitorClass_Details] details table matched the Class_Evolution it was summed up.
I am trying to create a measure which will calculate the Total Project Revenue
while I have 2 different projects. For each project there is a different calculation:
for Hourly project the calculation should be: Income * BillHours
for Retainer project the calculation should be: Income*TotalWorkinghours
I wrote the below DAX:
enter code here : Total project revenue = IF(max(DimProjects[ProjectType])="Hours",
max(FactWorkingHours[Income])[BillHours],max(FactWorkingHours[Income])*
[Total Working Hours])
the rows are calculated correctly but the total in the table is wrong
what should I fix in DAX so the total of all raw will correct as well.
The total Revenue should be 126,403.33
Thank you in advance
you can find here the table with the results
It's hard to say exactly what your measure is doing because, as written here, that is not a valid measure. I pasted it into the DAX Formatter, which I would recommend for formatting and pasting here into code blocks, and the measure was invalid. It would also be helpful to post the other measures this measure references, eg. [Bill Hours] and [Income Hours].
That being said, I think I can kind of tell what's going on. Your total is probably wrong because the filter context at the total level is being based of the condition where:
MAX ( DimProjects[ProjectType] ) = "Retainer" (or some other value not in your shared snippet)
That is because when you consider the MAX of a string, the higher alphabetical order is considered. Therefore, "Retainer" > "Hours". So at the total level, your table is outputting—more than likely, I can't be certain without more information—the false condition of your measure:
MAX ( FactWorkingHours[Income] ) * [Total Working Hours])
There is a better way to handle your intended outcome. IF statements, in the way you are attempting to use it, are rarely used in a calculated measure. You may be better off trying a calculated column without using the MAX functions. Again, I can't give an exact code recommendation without more context. Hope that sends you in the right direction!
I'm creating page in Power BI with custom KPI visuals (10-15 KPIs) made up of numerous measures for each KPI.
Note: when I say custom KPI visual I mean that each KPI visual is made up of other visuals combined together to appear as one visual, e.g.
an area chart, trending indicator icon (with conditional formatting measure to set the colour), current value, previous value, comparative text showing absolute change and % change, along with a couple of pieces of information
Basically each KPI is reporting a base metric and currently to build the visual(s) I am using 6-7 calculated measures. Multiply that by 10-15 metrics, I will end up with many calculated measures for this KPI page and a lot of the code will be duplicated for each base metric.
I've looked into using calculation groups but I just do think it will work for this scenario. Perhaps if I could pass a measure and calculation item as a field into any visual then it might.
It would be nice if I could create calcuation class with methods so that I can pass the base measure into the class using a method to return the derivative measure I need for the visual.
The class would continue all the calculations for the 6-7 pieces of information I need since the calculations for each piece of information are the same for base measure/metric.
Or essentially custom function(s) that take a measure a an argument that I can reuse for the 10-15 KPI metrics.
Something like:
[Total Sales].CurrentValue, [Total Sales].ComparableValue, [Total Sales].TrendIcon, [Total Sales].TrendIconColour, etc.
I'm really trying to avoid creating 70+ calculated measures and would rather just the 6-7 base calculations. Any solutions?
Thanks.
Is there any reason for using DAX measure such as SUM(Column1) instead of dropping the Column to table visual and then configuring the aggregation method in the table visual? Column1 contains numeric values only. I can see in Performance Analyzer that calculations take the same amount of time. Is there any scenario when DAX measure would be superior than using a numeric column directly? I have tested it on a larger model, using slicers and filters, and I consistently got the same duration for both methods.
When I copy DAX query code to DAX Studio I can see the drop Column method is expanded to CALCULATE(SUM. So it seems that if you just need SUM, then no need to create measure in DAX.
The difference here is explicit vs implicit measures. Explicit measures are the ones you define. Implicit measures are the ones automatically defined by Power BI.
In terms of performance, there is no difference. The engine is doing the same thing in both cases.
However, it's generally considered best practice not to use any implicit measures for a variety of reasons such as:
Explicit measures are reusable (useful as building blocks for more complex measures) and can be organized into display folders.
Implicit measures won't show up in external programs like Analyze in Excel.
See these articles for further information:
Explicit Vs Implicit DAX Measures in Power BI
Understanding Explicit vs Implicit measures in Power BI
Related Posts:
Efficiency of measures in power bi
RANKX() issues in DAX, PowerBI
https://community.powerbi.com/t5/Desktop/Implicit-versus-explicit-measures/td-p/1196134
got stuck with this one for a while. Need to repeat 165608547,90 in a Separate Column. Simple AVERAGEX(Sales[Turnover]) does not work. Thank you for any help
This would be best achieved through using a DAX measure.
Avg Cost = CALCULATE(AVERAGE('YourTable'[Amount]), ALL('YourTable'))
As per the comments added, if you want existing slicers to be respected, use ALLSELECTED in place of ALL. In some cases ALLEXCEPT could also be a solution.
Note, this must be a measure and not a column.
This measure will provide the average for everything in the table when it is added as a field in the matrix/table. The ALL keyword removes any filters applied to the data during the calculation.
See DAX ALL