How to pass slicer range to groupby value - powerbi

I want to find the sum of values groupby name according to time slicer visual in the powerBI
How can I achieve this?
name date value
Kelvin 10/01/1989 3
Peter 02/05/2018 4
Kelvin 02/02/2012 5
James 02/07/2014 2
Peter 04/01/2012 2

Related

Max if statement based on column

I have week no column that came from date, based on the max week no column I am trying to get the if statement yes or no.
Example: if week number column contain from 01 to 40 so 40 is the highest week no so I would like to get the result is Yes by using calculate column otherwise no.
Week No Deired Result
1 No
2 No
3 No
4 No
5 Yed
I got the answer...
IF(MAX(Table [weekno]) =Table [weekno], "Yes", "No".

How to group by on Power BI using DAX

I have two tables in Power BI as follows:
COUNTRIES
COD COUNTRY
1 BRAZIL
2 ARGENTINA
3 CHILE
4 BRASIL
5 COLOMBIA
6 ARGENTINA
7 URUGUAI
SALES
COD DATE
1 2021-01-02
2 2021-10-01
3 2019-09-04
1 2018-07-05
7 2019-04-10
There's a relationship between the two tables, on the COD column.
I need to count how many countries (column "COUNTRY" from the table "COUNTRIES") have a status CHURN. It's considered CHURN when their latest order from the table "SALES" is more than 180 days, using today as a reference.
I know that I need to group by the MAX date per country, do a DATEDIFF, and then do a COUNT. I've tried using ALL and SUMMARIZE, but I haven't found a way to solve this problem.
Are you able to add a calculated column to store the max sales date for each country in your COUNTRIES table? Either in Power BI or directly in your database. If so, here's one solution with 2 steps.
Create a MaxSalesDate column in your COUNTRIES table. DAX for a calculated column below:
MaxSalesDate =
VAR COD = COUNTRIES[COD]
RETURN MAXX(FILTER(SALES, SALES[COD] = COD), SALES[DATE])
Create a measure that counts the number of MaxSalesDate values that are older than 180 days old:
CountCHURN = COUNTX(COUNTRIES, IF(DATEDIFF(COUNTRIES[MaxSalesDate], TODAY(), Day) > 180, 1))

Microsoft Power BI: RANKX AND AGGREGATION OF RESULT

I am having an issues ranking a set of rows then getting the total to use as input to another calculation. I have attempted nested CALCULATE statements and intermediate table using CALCULATETABLE unsuccessfully.
Scenario is as follows:
Original table
Item Sales
A 3
B 4
C 2
D 7
E 5
Ranking top N (3)
Item Sales
D 7
E 5
B 4
TOTAL 16
In this example, I am interested in the value 16 for onward processing
Create a CALCULATED COLUMN to rank the sales.
Sale Rank = RANK.EQ(SalesData[Sales], SalesData[Sales])
Create a MEASURE to get the top 3 sales.
Top 3 Sales = CALCULATE(SUM(SalesData[Sales]), SalesData[Sale Rank] <= 3)

Power BI Measure: Aggregate By, Filter By, Group By, Simple Math

I am attempting to make a measure that calculates:
SUM(Num_Compliant) / SUM(Num_Asked) for a District, filtered to the current Fiscal Year (i.e. Date on or after 07/01/2018, or July 1, 2018).
District Date Section Num_Compliant Num_Asked
A 11/12/2018 I 3 8
A 1/12/2018 I 3 8
A 11/17/2018 II 1 6
A 5/18/2018 II 3 6
B 2/20/2019 I 4 8
B 4/20/2018 I 5 8
B 11/12/2018 II 6 6
B 1/12/2018 II 1 6
C 11/17/2018 I 2 8
C 5/18/2018 I 3 8
C 4/20/2018 II 5 6
With the above sample data, I expect the following results
District Numerator Denominator Value
A 4 14 0.29
B 10 14 0.71
C 2 8 0.25
I intentionally made the denominator different in district C to reflect the fact that sections are sometimes missing.
I have been trying to solve this for about a day, and am brand-new to Power BI, so I apologize if this is a very simple question.
The following measure looks like it solves your needs:
Value =
var __date = DATE(2018,7,1)
var __Numerator = CALCULATE(sum(Compliancy[Num_Compliant]),ALLEXCEPT(Compliancy,Compliancy[Distict]),Compliancy[Date]>__date)
var __Denominator = CALCULATE(sum(Compliancy[Num_asked]),ALLEXCEPT(Compliancy,Compliancy[Distict]),Compliancy[Date]>__date)
return __Numerator/__Denominator
Please note you will have to change "Compliancy" to your table name throughout the DAX formula. Also, the date is currently hard coded into the DAX, it might be best to use a date slicer so you can change the values on the fly. The measure without the date filter hard coded as is as follows:
Value =
var __Numerator = CALCULATE(sum(Compliancy[Num_Compliant]),ALLEXCEPT(Compliancy,Compliancy[Distict]))
var __Denominator = CALCULATE(sum(Compliancy[Num_asked]),ALLEXCEPT(Compliancy,Compliancy[Distict]))
return __Numerator/__Denominator
Table in Power BI:
As a side note of things to watch out for:
The measure "Value" needs to be set to the format "Decimal Place"
with 2 decimals.
The date field must be appropriately set to the
"Date" data type.

How to calculate last 4 any weekdays sales in power bi

I want to calculate last 4 any weekdays total sales.Based on filter max date.
Example: I have 2 filter
1. Date range(From -To)
2. Week Day(Like Mon,Tue Etc.)
I need total sales for last 4 Monday or Tuesday (as per above filter ).And Last 4 weekdays will be calculated based on To-date in filter.
Like To-date is 31-Dec'18 then last 4 Tuesday will be 4,11,18,25 Dec.
Thanks in advance for the help.
Nitika, the best way to do that is creating another table to put a 'Dimension' with dates, int that you can put, weekday, day, holiday, year, month...
Something like that:
Do You Need a Date Dimension?
Why use a Date Dimension Table in a Data Warehouse
Doing that you can reference your atual date with this table, and get just the weekday that you are looking for