Row wise total and % base on selection date - dax

I did measure column but total is incorrect.
LINE_Total = sumx(Report,Report[COMP_LINE]+Report[POSTED_LINE]+Report[REJECT_LINE]+Report[SUBMIT_LINE]+Report[WAPPR_LINE])
I understand- it is showing total and not considering selection date criteria. Please help me to include selection date criteria
System is not allowing me to include picture as example.
Thanks

Related

How do I Filter a Measure in a Graph in Power Bi based on a date

i have a bar Chart in Power Bi , where i want filter a certain Measure based on a Date.
It only should shown for every month who is not after than a certian date.
In my example its the end of June
i tried with Measures but it gives too much before.
Total Sales Filtered = CALCULATE([Total Sales],FILTER('Date','Date'[Date]<MAX(ClosedMonthsDates[Date])))
Where is my Mistake?
Nevermind, i figured out i just forget the equal ^^
Total Sales Filtered = CALCULATE([Total Sales],FILTER('Date','Date'[Date]<=MAX(ClosedMonthsDates[Date])))

Tableau - Fixed calculated field depending on date filter

I'm new to Tableau. I am trying to make an inventory report which tells the user how much of certain product he/she should buy in advance.
Depending on the amount of days selected on the filter, the difference in days of the complete period should be calculated. For example: If the filtered dates are from 1/03/2021 to 09/03/2021, the result should be equal to 9. The formula I used is the following: date_difference = DATEDIFF("day",MIN(DATE([Fecha])), MAX(DATE([Fecha]))) + 1
The problem comes when I try to use the value given by such date filter. My next calculation should be:
calc = Quantity Inventory / (Units sold / date_difference). Both Quantity Inventory and Units sold are calculated fields in which I have no problem. However, instead of having a fixed value of 9, date_difference changes as shown in the image, giving me incorrect results for the desired calculation.
How can I make sure that the calculated field date_difference has the value of 9 on all rows?. Actually, if I add date_difference field by itself in a different Page it does show the proper value. The problem occurs when calculating calc and trying to add it to the table.
Note: Remember that the value of date_difference will change, depending on the range of time selected on the date filter
Thanks a lot in advance.
Step-1 Use this calculation for date_difference instead
DATEDIFF('day', {min(DATE([Fecha]))}, {max(DATE([Fecha]))}) +1
Step-2 Add Fecha filter to context, by right clicking it in filters shelf.
This will solve your problem. See the GIF

Can you remove drill through filter from measures in Power BI?

I am trying to use the drill through filter to take my user to other data related to that date. Essentially I have an overview page and I want the user to click on a date and drill through to the next page, where it will show them test scores nearest to that date.
I think I need to do two things 1) store the filter date as a variable so I can use it to find the nearest test date to the filtered date 2) create measures which ignore the filtered drill through date and can for example calculate the minimum or maximum test scores on all the tests overall.
I'm not sure if either of these options are possible but any help is greatly appreciated. TIA

Calculating total number of days based on the relative date range filter in tableau

I have a date column using which I created a "relative date" filter as follows:
Now I want to create a measure as follows:
SUM(value from another column)/total number of day in that date range.
Can someone help me how to create this measure?? Thanks!!
Assuming you Record Date field is at the day level of detail, you could do:
SUM(value from another column)/countd(record_date)

Rank only for latest month

I've a calculated field "Total Revenue" which blends revenue from multiple data sources in Tableau.
Based on this field (aggregate field) on monthly basis, I would like to show only TOP 5 items with highest revenue as of latest month.
As shown in above table, items have to be filtered out (as they are TOP 5 in March) based on revenue data as of the latest month (March). How can this be achieved using RANK()? I'm not able to rank only for latest month as formulated below because it shows error as I cannot mix aggregate and non-aggregate functions.
IF DATETRUNC('month'),ReportDate)=//March 1st date given//
THEN RANK(Total Revenue)
END
My solution is a kind of workaround but seems to be working:
Create a calculated field with below formula:
IF DATEPART('month', {MAX([date])}) = DATEPART('month', [date])
and DATEPART('year', {MAX([date])}) = DATEPART('year', [date])
THEN
[revenue]
ELSE
0
END
The {MAX([date])} part on the code gets the maximum date in your data, it is fixed with { and } characters so that the value is not effected by the filters, date partitions etc. If you want the sorting month to be the one we are in then you should change that part with NOW()
Now we have a value containing only the sum of the latest month and we can sort our visual with this Measure.
You can drag your new measure (I called my measure: 'last month revenue') to the details and right click your item pill on the Rows, sort it by your new field.
And finally drag your item to the filters and go to Top tab, make filter your data according to sum of "last month revenue" measure.
Below screenshot shows the excel data and the final Tableau table:

Resources