Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi Team,
I have 5 column similar
Date | Country_Name | Count | BPID | RES/NON |
20-May-20 | INDIA | 20 | Z10 | RES |
20-May-20 | INDIA | 15 | Z12 | NONRES |
20-May-20 | AMERICA | 10 | z12 | RES |
20-May-20 | South africa | 30 | Z10 | RES |
21-May-20 | INDIA | 25 | Z10 | RES |
21-May-20 | INDIA | 25 | Z14 | RES |
21-May-20 | AMERICA | 10 | Z12 | RES |
21-May-20 | South africa | 25 | Z15 | NONRES |
24-May-20 | INDIA | 30 | Z20 | NONRES |
24-May-20 | INDIA | 34 | Z20 | RES |
24-May-20 | AMERICA | 10 | Z35 | RES |
24-May-20 | South africa | 34 | Z10 | NONRES
|
I need If select one date same month 1st date average required(average formala=SUM(countcolumn values)/COUNT(no .of dates)
If i am select 24th may the data availble 21 then out shoube INDIA output =(20+15+25+25+30+34)/3=49.6
if i am select jan 27 then average shoube 01-jan to 27-jan
if i am select 15-jan then average shoulbe 01-jan to 15-jan
similar select date to same month 1st average required please help me.
if i am select 20-Feb then average shoulbemonth 01-feb to 20-15
Thanks
Shanvitha
Solved! Go to Solution.
@Anonymous , see like you are looking for Month till date, You have totalmtd and datesmtd to help. Use them with a date table
examples
MTD Sales = CALCULATE(Sum(Sales[Sales Amount]),DATESMTD('Date'[Date]))
MTD Dates= CALCULATE(distinctcount(Sales[Sales Date]),DATESMTD('Date'[Date]))
Avg = divide([MTD Sales],[MTD Dates])
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
Appreciate your Kudos.
Hi @Anonymous ,
At first, use DISTINCT() to create a date dimension table based on your fact table.
Then refer to the following measure:
Measure =
VAR a =
SELECTEDVALUE ( 'Date'[Date] )
VAR b =
CALCULATE (
MIN ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Column] = SELECTEDVALUE ( 'Date'[Column] ) )
)
VAR total =
CALCULATE (
SUM ( 'Table'[Count] ),
FILTER ( 'Table', 'Table'[Date] >= b && 'Table'[Date] <= a )
)
VAR day =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Date] >= b && 'Table'[Date] <= a )
)
RETURN
DIVIDE ( total, day )
Here is my test file for your reference.
Hi @Anonymous ,
At first, use DISTINCT() to create a date dimension table based on your fact table.
Then refer to the following measure:
Measure =
VAR a =
SELECTEDVALUE ( 'Date'[Date] )
VAR b =
CALCULATE (
MIN ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Column] = SELECTEDVALUE ( 'Date'[Column] ) )
)
VAR total =
CALCULATE (
SUM ( 'Table'[Count] ),
FILTER ( 'Table', 'Table'[Date] >= b && 'Table'[Date] <= a )
)
VAR day =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Date] >= b && 'Table'[Date] <= a )
)
RETURN
DIVIDE ( total, day )
Here is my test file for your reference.
@Anonymous , see like you are looking for Month till date, You have totalmtd and datesmtd to help. Use them with a date table
examples
MTD Sales = CALCULATE(Sum(Sales[Sales Amount]),DATESMTD('Date'[Date]))
MTD Dates= CALCULATE(distinctcount(Sales[Sales Date]),DATESMTD('Date'[Date]))
Avg = divide([MTD Sales],[MTD Dates])
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
Appreciate your Kudos.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
96 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |