The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
CONTEXT:
I have a table with different room transactions(reservations), I'm trying to calculate the number of nights between two dates so I can usem them in a pivot table or any graph, like this:
This result is not correct because I should have in december(diciembre) 8 instead of 9 and that 1 remaning should go to january, and so on.
QUESTION:
How to create a DAX or how to solve this issue.
Solved! Go to Solution.
Hi, I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file whether it suits your requirement.
expected result measure: =
VAR _currentmonth =
MAX ( 'Calendar'[Year-Month sort] )
VAR _t =
GENERATE (
Data,
FILTER (
'Calendar',
'Calendar'[Date] > Data[Start]
&& 'Calendar'[Date] <= Data[End]
)
)
RETURN
COUNTROWS ( FILTER ( _t, 'Calendar'[Year-Month sort] = _currentmonth ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi, I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file whether it suits your requirement.
expected result measure: =
VAR _currentmonth =
MAX ( 'Calendar'[Year-Month sort] )
VAR _t =
GENERATE (
Data,
FILTER (
'Calendar',
'Calendar'[Date] > Data[Start]
&& 'Calendar'[Date] <= Data[End]
)
)
RETURN
COUNTROWS ( FILTER ( _t, 'Calendar'[Year-Month sort] = _currentmonth ) )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
I think it works, but before I marked it as a solution, I need to know if this will work with other visuals, for example a line chart, or to create other measures with it
Hi, thank you for your message, and please provide your sample pbix file and then I can try to look into it.
Thanks.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
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 August 2024 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
18 | |
18 | |
15 | |
13 |
User | Count |
---|---|
42 | |
36 | |
23 | |
22 | |
17 |