How to calculate sum of distinct in SSRS - grouping

After grouping country, i am getting total as 150. But as per requirement it should be 120. How to achieve this??
Tried =SUM(Fields!Amt.Value,"GroupCtry") --> Gives an error.
Tried SUM(DISTINCT(Amt) at database level, still no success. Using Syabse ASE.
Any leads, on how to do this??
TIA!

Related

Powerbi Matrix issues with the value field

I have a problem with Powerbi I can't seem to fix. If the answer is obvious i am sorry but i am just starting out with Powerbi.
We are trying to make a dashboard that will show if a coworker is available or not based on a code 1 -3).
We check their availability per ISOWeek. If they don't have work that week they get code 1, when they have work code 2 etc.
These codes show up the right way in SQL but when I want to add them in my matrix table and have the coworker names on the rows, the ISOWeek on the columns and then when i add the Code in values Powerbi wants to show the total, total(distinct), first or last.
The problem is it wont use the code it got per isoweek. Is there a solution for this?
Thanks in advance!
What is should look like in the matrix:
Fixed it by giving the columns: don't Summarize on the modeling tab. Then I gave the code column the minimum value for each week.

How to compute a cumulative percent on multiple categories in DAX?

I'd like to compute a line graph showing the running percent between the actuals and open-orders with the forecast.
Here is a sample of my data structure:
data structure
Here is the problem i currently have: problematic running percent line
As you can see, the percent is not cumulative.
Finally, here is the dax expression i'm currently stuck with (tried other formulas, to no avail): dax expression
Any hint, insight or help is more than welcome!

Unable to execute measure stored in Analysis Services/Power BI

I'm trying to see if I can write tests in C# that will validate the measures in a model; to do I need to execute the measure and compare the result with an implementation in C# that should be the same.
I've set up a basic Power BI-report containing a couple of tables and measures. One of the measures is a simple count('fact_data'[Item]), and works as expected when I'm looking at it in the report.
When connecting to the model via ADOMD.NET I'm able to extract the measure expression programmatically, but when I try to run it via the AdomdDataAdapter all I get is
AdomdErrorResponseException: Query (1, 18) The syntax for '[Item]' is incorrect. (COUNT('fact_data'[Item])).
Other and more basic queries where I simply return table contents work without problem.
No matter what I try I cannot get this to execute; if I rename the column or table to something that doesn't exist, I get an error about this so it would seem that the query is executed, but that something is either wrong or missing in the syntax.
I still don't know how to do this via ExecuteScalar(), but wrapping the DAX in a ROW() seems to work for stored measures.

Creating a measure using DAX function Left on a table from Azure Analysis service

I am trying to get the first 4 digits from a string from a table in Power BI. The connection is a live connection / Direct which does not allow me to edit the query. Also, I am unable to create a new column. So I have to stick with creating a new Measure.
Now, I am using the following formula to get what I need.
LocationCd = mid(vw_DW_Contracts[ContractNumber],1,5)
but, this is not working a the vw_DW_Contracts table cannot be used in a measure. Is there a workaround to such problem?
I do not have access to the analysis service so cannot make any modifications in the source.
Please help.
Thanks
but, this is not working a the vw_DW_Contracts table cannot be used in a measure.
I'm not sure what you mean by this, but I'm guessing the message you see is telling you that measures expect an aggregation. The formula you posted would be great as a calculated column where it can be evaluated row by row. Measures are aggregations over multiple rows.
If you are trying to make a new field that is the location code that can be used in visuals on a categorical axis, this should be a column rather than a measure. You could write a measure to show a location cd using something like LASTNONBLANK (mid(vw_DW_Contracts[ContractNumber],1,5), 1) but I doubt that is what you want.

Restrict filtering of measure in Power BI

Can someone help me finding a way to restrict a measure getting filtered in Power BI?
I have a visual that displays the percentage of manual activities occurred in a particular region. The calculation done is
RegionManualActivityCount*100/CountryManualActivityCount
I have around 10 regions in a country and I have wrote a general measure to do the calculation. In Power BI for each region's visual I have a visual filter applied based on Region Name. But the problem is the CountryManualActivityCount is also getting filtered based on Region Name. I do not want the CountryManualActivityCount in the measure calculation to be filtered.
Can someone help me with this?
you can use the Dax function ALL or ALLEXCEPT to remove the applied filters to your report.
Something like CALCULATE(Table,RegionManualActivityCount*100/CountryManualActivityCount,ALL(Table[RegionName]))
It will remove your filters on Region Name in this particular measure.