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!
I have a dynamic graph which show me dates in period from January to July
I need to write query in DAX which add autamatically august dates in my graph if today is >=10,
for instance, today is 6 September, so my graph will show me all dates between 1 January and 31 July, but
if the day of current month (in our case is September) is >= 10 (for instance today is 11 September), so query automatically have to add previous month dates (august)
So, I wrote something like that:
Column = if(day(TODAY()) >= 10, IF('DT'[Date] < TODAY()-10,1,MAX(EOMONTH(TODAY(),-2),0))) - but it doesnt return what I expect
but Im not sure, should it be like new column or new measure? Because I will use it like filter for my dashboards...
So, the logic of the query look pretty simple, if day of today is >= 10, then add previous month to graph (from start of the year (1 January)till the last day of previous month (31 August),
in other case - show me all dates till the current month - 2 (so, all dates in range between 1 January and 31 July)
This filter would help me to avoid add manualy every new month to my graph... I would like to write query which do it automatically
Please, share me your opinions and advices.
Many thanks in advance!
Hi @vvza,
Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Can not add file (.pbix) dont kow why(The file type (".pbix) is not supported."-that`s the reason probably), but there is simple graph which show dates for 7 month, so I would like create a filter what add next month automatically, because now I need to choose after 10th September previous month manually on my filter (you can see it on this screen, month number 8 = August). So, if today day is >=10 then add august to my graph, otherwise show all dates till 31 july (last day of 2 month ago from today)
I managed to write something like this
HI @vvza,
You can try to use the following measure formula to calculate the rolling two-month amount based on the current date.
if the current system date is larger than the 10th, the current month's records will be included in the cumulative calculation; if not, the rolling calculation will calculate until the previous month's end.
formula =
IF (
DAY ( TODAY () ) >= 10,
CALCULATE (
SUM ( Table[Amount] ),
FILTER (
ALLSELECTED ( Table ),
[Date]
>= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 2, DAY ( TODAY () ) )
)
),
CALCULATE (
SUM ( Table[Amount] ),
FILTER (
ALLSELECTED ( Table ),
[Date]
>= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 2, DAY ( TODAY () ) )
&& [Date]
<= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 ) - 1
)
)
)
Regards,
Xiaoxin Sheng
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 |
---|---|
108 | |
98 | |
78 | |
66 | |
53 |
User | Count |
---|---|
139 | |
100 | |
95 | |
85 | |
63 |