Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 ) )
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 ) )
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.
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
25 | |
12 | |
11 | |
10 | |
6 |