I have the following chart which shows sick leave per person for July and August and on top of that is a card that shows the average of all the months, so in this case is average of July and August which gives 1.55.
Instead of the average, I want the card to show the latest value of the month, so in this case I want the card to show August value which is 0.79 and when September data is loaded, I want the card to show September data instead, unless someone clicks on a different month, then the card should update to show average of what they selected.
For the measure to show the latest months data you could do something like this
Latest Month Average =
VAR latest_month =
MONTH ( CALCULATE ( MAX ( 'Table'[SickDate] ) ) )
RETURN
CALCULATE (
AVERAGEX ( VALUES ( 'Table'[Person] ), COUNT ( 'Table'[SickDate] ) ),
FILTER ( 'Table', MONTH ( 'Table'[SickDate] ) = latest_month )
)
Im not sure what you're data looks like so im making assumptions based on your visual
So im assuming a table like this
Person
SickDate
Jim
Thursday, 1 September 2022
Jane
Thursday, 1 September 2022
John
Saturday, 1 October 2022
Jim
Thursday, 1 September 2022
Jane
Thursday, 1 September 2022
John
Saturday, 1 October 2022
Phil
Sunday, 2 October 2022
So the measure basically gets the latest month in the data
Counts the amount of dates (sick days) by person and takes an average
Note: if you're showing multiple years you would need to get the latest month and year to filter correctly and not just month
Related
Outlet ID
Outlet Name
Order Date
Product
Qty
Net Value
Mum_1
Prime Traders
12th Oct 2022
RoundBox
3
300
Mum_4
Avon Trading
13th Oct 2022
Slice 100
10
1000
I have date wise transaction data for past 20 months for retail outlets.
Any outlet that has been billed in the last 3 months can be classified as an 'Available Outlet'.
Eg: Available outlets for Sept 2022 are the ones that have been billed at least once across July, August & Sept 2022.
Similarly I need to have ,month wise availability count in a column chart. Can someone please guide as to how can I write a DAX query for the same ?
I am new to Power BI.I have one year filter (Range filter) and one week number filter (Range filter). I want to calculate values such that when i select year 2021 to 2022 and week number 42 to 10 it will first show data for 42th weeks to 52th weeks for year 2021 and for 1st week to 10 th weeks for year 2022.
I have two tables in PowerBI, one modified date and one fact for customer scores. The relationship will be using the "Month Num" column. Score assessments take place every June, so I would like to be able to have the scores for 12 months (June 1 to June 30) averaged. Then I will just have a card comparing the Previous year score and Current year score. Is there a way to do this dynamically, so I do not have to change the year in the function every new year? I know using the AVERAGE function will be nested into the function somehow, but I am getting confused not using a calendar year and not seasoned enough to use Time Intelligence functions yet.
Customer Score Table
Month
Month Num
Year
Score
Customer #
June
6
2020
94.9
11111
July
7
2020
97
11111
months
continue
2020
100
June
6
2021
89
22222
July
7
2021
91
22222
months
continue
2021
100
June
6
2022
93
33333
July
7
2022
94
33333
Date Table
Month
Month Num
Month Initial
january
1
J
feb
2
F
march
3
M
other
months
continued
I have below Customer Transactions data. In a month, customer may buy one or multiple times data pack ,or may not buy data pack.
Irrespective of how many times data purchased in a month by a customer. I'm trying to find number of months that each customer purchased the data.
Total Subscribed Months is expected column.
Since customer may buy Data Subscribed (GB) more than once in a month. First I'm calculating Total Data Purchased in a month by customer.
Total Data Purchased = CALCULATE(
SUM('Customer Transactions'[Data Subscribed (GB)]),
ALLEXCEPT('Customer Transactions','Customer Transactions'[Account Number],'Customer Transactions'[Date])
)
Second, Calculate number of months customer purchased the data pack.
Total Subscribed Months =
CALCULATE(
DISTINCTCOUNT('Customer Transactions'[Account Number] ),
'Customer Transactions'[Total Data Purchased]>0
)
But its not working. Please advise how to correct formulae ?
Assuming your table looks like this:
Account Number
CUSTOMER_TYPE
Data Subscribed(GB)
Free Data
Date
Total Subscribed Months
10001
Retail
250
0
01 October 2019
1
10001
Retail
0
100
01 November 2019
1
10002
Retail
200
0
01 October 2019
1
10002
Retail
250
0
01 November 2019
2
10003
Retail
300
0
01 October 2019
2
10003
Retail
0
0
01 October 2019
2
10003
Retail
100
0
01 October 2019
2
10003
Retail
100
0
01 November 2019
2
10003
Retail
100
0
01 November 2019
2
10003
Retail
0
0
01 December 2019
2
DAX Calculations
Total Subscribed Months
Total Subscribed Months =
CALCULATE (
DISTINCTCOUNT ( 'Customer Transactions'[Date] ),
FILTER ( ALL ( 'Customer Transactions'[Data Subscribed(GB)] ), [Data Subscribed(GB)] > 0 )
)
Total Data Purchased
Total Data Purchased =
SUM('Customer Transactions'[Data Subscribed(GB)])
Output
Table visual with Account Number, Total Subscribed Months and Total Data Purchased.
Excel Example
I am attempting to recreate a similar chart in PowerBI as I did in excel seen below:
Here I have revenue per day. The chart shows the percent of days where revenue exceeds a fixed amount (100, 200, etc).
In PowerBI I know how to recreate the table that the chart is based on by defining a column, but it's not dynamic. I can't apply filters to change the column values.
I know I can apply filters to measures but when I try to replicate the formula as a measure I get an error, which I assume is due to the formula trying to return an array of values.
Here is my formula for the fixed column version:
table2 column = countx(
filter(
DayRevenueTable,
[Revenue]>Table2[DayRevenueExceeding])
,[Day])
/Total
Assuming your table looks like this:
Date
Revenue
04 January 2022
102
11 January 2022
162
17 January 2022
180
02 January 2022
185
12 January 2022
203
05 January 2022
278
01 January 2022
353
16 January 2022
449
14 January 2022
500
06 January 2022
515
08 January 2022
582
10 January 2022
600
03 January 2022
618
09 January 2022
626
13 January 2022
626
15 January 2022
706
18 January 2022
765
07 January 2022
895
You need to first create a table with your fixed values. Basically is the same concept as creating a parameter.
Using that table as a reference, you can create your calculation around Fixed Values[Value].
DAX: Fixed Values
Fixed Values = GENERATESERIES(100,1000,100)
DAX: Days When Revenue Exceeds Amount
Days When Revenue Exceeds Amount =
VAR CurrentFixedValue =
SELECTEDVALUE ( 'Fixed Values'[Value] )
VAR CountValues =
CALCULATE (
COUNTROWS ( 'Table' ),
'Table'[Revenue] < ( CurrentFixedValue + 100 )
)
VAR AllValues =
CALCULATE ( COUNTROWS ( 'Table' ), ALLSELECTED ( 'Table' ) )
VAR Calc =
DIVIDE ( CountValues, AllValues )
RETURN
Calc
Output