Power bi % in table from a measure - dax

I need to calculate % for each value from "G. Directos Año Actual" from the measure "Ventas Año Actual"
Imagen adjunta

That is very little information to go on, but assuming "G. Directos Año Actual" is a column that can be used as a dimension for the "Ventas Año Actual" measure, and that column is providing row context in whatever visual you use, this will get you the % of total for each G. Directos Año Actual.
% of Ventas Año Actual = DIVIDE(
[Ventas Año Actual]
, CALCULATE([Ventas Año Actual], REMOVEFILTERS('Unknown Table Name'[G. Directos Año Actual]))
)

Related

Calculate weights for a similarity score

Assume there is a dataset as follows:
dataA: {
attribute1: x,
attribute2: y,
attribute3: z
}
I want to calculate the correlation between similar structured data (Eg: dataA, dataB, dataC ...)
And I have a similarity measure for each attribute of each dataset. (Eg: similarity of x with other values of attribute1 is 0.11, similarity of y with other values of attribute2 is 0.22, similarity of z with other values of attribute3 is 0.33)
I'm going to present the correlation score in a weighted average approach where a weight is defined for each attribute (Eg: weight of attribute1 is w1 etc.):
Score for dataA = { (0.11 x w1) + (0.22 x w2) + (0.33 x w3) } / {w1 + w2 + w3}
If I'm going to conduct an experiment to find the optimal weights, how can I do it?
UPDATE:
Can I conduct an experiment to check the probability of each attribute value to be changed and then use that value somehow?
How about the assignment problem or the simplex method?

calculate first,second,third derivative on 3d image

really i have a problem to calculate first , second , third derivative on 3d image with matlab.
i have 60 slice of dicom format of knee mri , and i wanna calculate derivative .
for 2d image when we want to calculate derivative on x or y direction ,for example we use sobel or another operator in x direction for calculate derivative on x direction .
but in 3d image that i have 60 slices of dicom format , how can i calculate first, second ,and third derivative on x ,y,z directions .
i implement like this for first derivative :
F is 3d matrix that has all slices. [k,l,m] = size(F);
but i think it's not true .please help me , really i need your answers .
how can we calculate first, second, third derivative on x ,y ,z directions .?
case 'x'
D(1,:,:) = (F(2,:,:) - F(1,:,:));
D(k,:,:) = (F(k,:,:) - F(k-1,:,:));
D(2:k-1,:,:) = (F(3:k,:,:)-F(1:k-2,:,:))/2;
case 'y'
D(:,1,:) = (F(:,2,:) - F(:,1,:));
D(:,l,:) = (F(:,l,:) - F(:,l-1,:));
D(:,2:l-1,:) = (F(:,3:l,:)-F(:,1:l-2,:))/2;
case 'z'
D(:,:,1) = (F(:,:,2) - F(:,:,1));
D(:,:,m) = (F(:,:,m) - F(:,:,m-1));
D(:,:,2:m-1) = (F(:,:,3:m)-F(:,:,1:m-2))/2;
There is a function for that! Look up https://www.mathworks.com/help/images/ref/imgradient3.html, where there are options to indicate the kind of gradient computation: sobel is the default.
If you'd like directional gradients, consider using https://www.mathworks.com/help/images/ref/imgradientxyz.html, which has the same options available, but returns the directional gradients Gx, Gy and Gz.
volData = load('mri');
sz = volData.siz;
vol = squeeze(volData.D);
[Gx, Gy, Gz] = imgradientxyz(vol);
Note that these functions were introduced in R2016a.
The "first derivative" in higher dimensions is called a gradient vector. There are many formulas to numerically approximate the gradient, and one of the most accurate approaches is disccused in a recent paper: "High Order Spatial Generalization of 2D and 3D Isotropic Discrete Gradient Operators with Fast Evaluation on GPUs" by Leclaire et al.
Higher order derivatives in more than one dimension are tensors. The "second derivative" in particular is a rank-2 tensor and has 6 independent components, which to the lowest order approximation are
Dxx(x,y,z) = (F(x+1,y,z) - 2*F(x,y,z) + F(x-1,y,z))/2
Dyy(x,y,z) = (F(x,y+1,z) - 2*F(x,y,z) + F(x,y-1,z))/2
Dzz(x,y,z) = (F(x,y,z+1) - 2*F(x,y,z) + F(x,y,z-1))/2
Dxy(x,y,z) = (F(x+1,y+1,z) - F(x+1,y-1,z) - F(x-1,y+1,z) + F(x-1,y-1,z))/4
Dxz(x,y,z) = (F(x+1,y,z+1) - F(x+1,y,z-1) - F(x-1,y,z+1) + F(x-1,y,z-1))/4
Dyz(x,y,z) = (F(x,y+1,z+1) - F(x,y+1,z-1) - F(x,y-1,z+1) + F(x,y-1,z-1))/4
The "third derivative" will be a rank-3 tensor and will have even more components. The formulas are lenghty and can be derived by considering a Taylor series expansion of F up to the 3rd order

Plotting median of an image on image coordinates

I have a gray scale image. I want to plot the median of the columns of that image on to the image axis. For doing this I need to have two things:
median values of the columns (which i can obtain using the Matlab's Median command) and
the position of median value in image coordinate.
Can anyone help me or give a hint or an idea or any function for estimating the median position?
This code marks all gray-scale level values in a given column equal to median value for that column:
load clown
M = median(X, 1);
figure();
imshow(uint8(X));
hold on;
for columnIdx = 1:numel(M)
medianValue = M(columnIdx);
% find locations of gray-scale lavel values equal to the median
idx = find(X(:, columnIdx) == medianValue);
if numel(idx) > 0
% mark all the gray-scale level values on the image
plot(ones(1,numel(idx)) * columnIdx, idx, '.g');
end
end
Hope it helps

two dimensional histogram of an image in matlab

I have an image. i am calculating I,u,v components for it.
I = (R+G+B)/3
u = R-G
v= G-B;
Now , I want to find two-dimensional histograms
over the chromatic information (u; v).
Thanks in advance.
You can use sparse to creatre a sparse 2D matrix that counts the u-v entries.
Note that you'll have to adjust the indices in the u-v dimension to be in range 1...|u| and 1...|v| (and not negative or fractional).
[uu ui] = unique( round(u(:)) ); % adjust u index using unique command
[vv vi] = unique( round(v(:)) );
twoDhist = sparse( ui, vi, 1, numel(uu), numel(vv) );
twoDhist = spfun( #(x) x/numel(ui), twoDhist ); % normalize hist to sum to 1
figure;
imagesc( vv, uu, twoDhist ); colormap jet; colorbar; axis image

Superimpose images MATLAB(grey with color)

I have two matrices, the first is the ROI from an dicom image (grey scale) and the second is a matrix with values between 0-1.
In the second matrix I did a thresholding and kept only the values of a range (0.6 -1.0). I would like to superimpose the two matrices-images and show the result as an figure, that means background the grey image and superimposed the color image (in the region of non zero values).
Can you provide me with some help?
Thanks
How about
figure;
imshow( first(:,:,[1 1 1]) ); % make the first a grey-scale image with three channels so it will not be affected by the colormap later on
hold on;
t_second = second .* ( second >= .6 & second <= 1.0 ); % threshold second image
ih = imshow( t_second );
set( ih, 'AlphaData', t_second );
colormap jet

Resources