The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I want to build a cumulative graph of the Items column. The problem is that currently, I would like if the date does not exist in the Date column, to still continue the cumulative calculation until today's date. Currently, the cumulative will display the value 2 for the date 2024-03-20, then continue with the date 2024-03-22 with the value 3. So, there are not the date 2024-03-21. But, I want that at 2024-03-21, it will return the value 2.
THANKS.
It must give sommething like this:
Solved! Go to Solution.
Good Morning,
do You have a DateTable ?
if not you can create one by using this code:
DIM_Datetable =
VAR calender =
CALENDAR(
Date( 2020,01,01 -- FirstDate
),
DATE(
2030,01,01 -- Last Date
)
)
RETURN
ADDCOLUMNS(
calender,
Year,YEAR([Date]),
Quarter, CONCATENATE(Q,QUARTER([Date])),
Year Month, YEAR([Date]) & - & FORMAT(MONTH([Date]), 00),
Month, MONTH([Date]),
Month Name, FORMAT([Date], MMMM),
Day of year, DATEDIFF(DATE(YEAR([Date]),1,1),[Date],DAY)+1,
Day of Month, DAY([Date]),
Day of week, WEEKDAY([Date],2),
Day Name, FORMAT([Date], DDDD),
Weeknum, FORMAT(WEEKNUM([Date],2),00),
Year Weeknum, YEAR([Date]) & FORMAT(WEEKNUM([Date],2),00),
Year Quarter, YEAR([Date]) & - & QUARTER([Date])
)
This code will create a date table including the dates you specify. After creating this table You can connect it with your fact table by a one to many relationship then use the date table instead of your date column in your graph.
Let me know if this was useful!
Hi @game1
There are two possibilities. The first one will require a date table as @DAX_Machine suggested. When the data model is set up correctly you can use the Date from the Date table in the visual and then add this measure
RunningTotal =
VAR MaxDate =
MAX ( DIM_Date[Date] )
RETURN
CALCULATE (
COUNTROWS(Table),
KEEPFILTERS ( 'Table'[Date] <= MaxDate
&& 'Table'[Date] >= MaxDate,
ALL ( DIM_Date )
If a Date table isn't an option you can try @Greg_Deckler solution
The Case for No CALCULATE (linkedin.com)
RunningTotal =
VAR __Date = MAX('Table'[Date])
VAR __Table = FILTER(ALLSELECTED('Table'),[Date] <= __Date)
VAR __Result = COUNTX(__Table,[Items])
RETURN
__Result
Hope this helps
Joe
If you found my answer helpful and it solved your issue, please accept as solution
Hi @game1
There are two possibilities. The first one will require a date table as @DAX_Machine suggested. When the data model is set up correctly you can use the Date from the Date table in the visual and then add this measure
RunningTotal =
VAR MaxDate =
MAX ( DIM_Date[Date] )
RETURN
CALCULATE (
COUNTROWS(Table),
KEEPFILTERS ( 'Table'[Date] <= MaxDate
&& 'Table'[Date] >= MaxDate,
ALL ( DIM_Date )
If a Date table isn't an option you can try @Greg_Deckler solution
The Case for No CALCULATE (linkedin.com)
RunningTotal =
VAR __Date = MAX('Table'[Date])
VAR __Table = FILTER(ALLSELECTED('Table'),[Date] <= __Date)
VAR __Result = COUNTX(__Table,[Items])
RETURN
__Result
Hope this helps
Joe
If you found my answer helpful and it solved your issue, please accept as solution
Good Morning,
do You have a DateTable ?
if not you can create one by using this code:
DIM_Datetable =
VAR calender =
CALENDAR(
Date( 2020,01,01 -- FirstDate
),
DATE(
2030,01,01 -- Last Date
)
)
RETURN
ADDCOLUMNS(
calender,
Year,YEAR([Date]),
Quarter, CONCATENATE(Q,QUARTER([Date])),
Year Month, YEAR([Date]) & - & FORMAT(MONTH([Date]), 00),
Month, MONTH([Date]),
Month Name, FORMAT([Date], MMMM),
Day of year, DATEDIFF(DATE(YEAR([Date]),1,1),[Date],DAY)+1,
Day of Month, DAY([Date]),
Day of week, WEEKDAY([Date],2),
Day Name, FORMAT([Date], DDDD),
Weeknum, FORMAT(WEEKNUM([Date],2),00),
Year Weeknum, YEAR([Date]) & FORMAT(WEEKNUM([Date],2),00),
Year Quarter, YEAR([Date]) & - & QUARTER([Date])
)
This code will create a date table including the dates you specify. After creating this table You can connect it with your fact table by a one to many relationship then use the date table instead of your date column in your graph.
Let me know if this was useful!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
56 | |
32 | |
20 | |
17 | |
15 |
User | Count |
---|---|
53 | |
31 | |
30 | |
23 | |
21 |