Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello experts,
couldn't find a smilar matching topic so I created this one.
I need your help to correct Dax measures which are counting rows older or younger than a given date.
There is an order table with a due date column. I want to count orders according to that due date in relative to today.
Let's say I want to count open orders in a range of +/- 7 days from today.
I managed to set the correct date range dynamically and to count orders in that range for any given day.
But I also want show whats before and after the given date range and I struggle with it. How can I modify my counting measures to display the count of all orders before the date range begins and after the date range has ended.
When you look at the image, I my table I want in the date column as first entry "older" which counts 9 orders and another entry "after" which should count 49 orders. Alternatively count this orders and add it to first or last day of the date range. Then the 6th Aug would show "11" and the 27th Sep would show "52".
Anyone has an idea?
My counting measures:
I set a filter to "1" on the following measure to dynmaically create the x-axis (first column):
SLA_Monitor Filter Range = IF(SELECTEDVALUE(orders[t_sla_end])>=TODAY()-7 && SELECTEDVALUE(orders[t_sla_end])<=TODAY()+7,1,BLANK())
Thank you and BR
cfg
Solved! Go to Solution.
@C-F-G recommendation would be to add a relationship or use treatas function:
Sales Measure =
VAR __StartDate = TODAY () - 7
VAR __DatesTable = DATESINPERIOD ( 'Calendar'[Date], __StartDate, 14, DAY )
RETURN
CALCULATE (
SUM ( Table[Sales] ),
TREATAS (
__DatesTable,
Table[Date Column You Want To Use]
)
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@C-F-G recommendation would be to add a relationship or use treatas function:
Sales Measure =
VAR __StartDate = TODAY () - 7
VAR __DatesTable = DATESINPERIOD ( 'Calendar'[Date], __StartDate, 14, DAY )
RETURN
CALCULATE (
SUM ( Table[Sales] ),
TREATAS (
__DatesTable,
Table[Date Column You Want To Use]
)
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you, parry2k.
The use of TREATAS looks very promising.
I will work on this approach.👍
Hi, @C-F-G
May I ask if you have gotten this issue resolved? If it is solved, please share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.
If it is not resolved, I hope you will provide the full .pbix file via OneDrive or SharePoint. Please be careful to remove all sensitive information and we will do our best to provide ideas for your issue.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
thank you for trying to help.
Unfortunately I couldn't resolve it yet.
A change in the data model is needed. But I can't do that myself while working on a live connection to an analysis server. I need to contact the other department in order to place my change request.
Nevertheless, thank you very much for your effort.
cfg
As a best practice, add a date dimension in your model and use it for time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools. Check the related videos on my YT channel
Add Date Dimension
Importance of Date Dimension
Mark date dimension as a date table - why and how?
Time Intelligence Playlist
For your calculation you can simply use the following measure to get -/+ 7 days from today:
Sales Measure =
VAR __StartDate = TODAY () - 7
RETURN
CALCULATE (
SUM ( Table[Sales] ),
DATESINPERIOD ( 'Calendar'[Date], __StartDate, 14, DAY )
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi parry2k,
thank you for pointing out the importance of a date table.
There is already a date table defined in the model I'm working with. Unfortunately it is linked to other date fields in the order table. I'm working with a live connection on an analysis server and can't change the data model. I have to contact other department to create an (inactive) relationship between the date table and my desired date field. I tried to work around this but it seems it isn't posssible ...
Nevertheless, thank you very much for your effort.
cfg
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
111 | |
96 | |
89 | |
38 | |
28 |