Forum Discussion
Calculating Elapsed QTD
- Anonymous3 years ago
Hi jbuzaglu ,
Here's my solution.
1.Create a calendar table by dax.
Calendar = ADDCOLUMNS(CALENDAR(DATE(2023,1,1),DATE(2023,12,31)),"Quarter",QUARTER([Date]))2.Create a measure return the percentage.
Elapsed QTD = VAR _CALENDAR = SUMMARIZE ( CALENDAR ( DATE ( 2023, 1, 1 ), DATE ( 2023, 12, 31 ) ), [Date], "Quarter", QUARTER ( [Date] ) ) VAR _min = CALCULATE ( MIN ( 'Calendar'[Date] ), FILTER ( ALL ( 'Calendar' ), [Quarter] = QUARTER ( TODAY () ) ) ) VAR _MAX = CALCULATE ( MAX ( 'Calendar'[Date] ), FILTER ( ALL ( 'Calendar' ), [Quarter] = QUARTER ( TODAY () ) ) ) VAR _DAYS = COUNTROWS ( FILTER ( 'Calendar', [Date] >= _min && [Date] <= _MAX ) ) VAR _DAYS2 = COUNTROWS ( FILTER ( 'Calendar', [Date] <= TODAY () && [Date] >= _min ) ) RETURN DIVIDE ( _DAYS2, _DAYS )Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you've got a date table, you can follow the guide here: https://community.powerbi.com/t5/Desktop/DAX-formula-for-counting-number-of-days-in-the-quarrter/m-p/593157
If not, I highly suggest making one! It makes a lot of date calculations more convenient. As for the percentage, once you've worked out the elapsed days, getting the percentage should hopefully be straightforward.