Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello ,
I have data like this....many rows per ID based on the Med_Taken_time. Otherwise the other rows are same for an ID
I want to calculate Numerator and Denominator.
Numerator: Count of ID's in the 1,2, or 3 categories with Med_taken_time 12 hours from admission
Denominator: Count of ID's in all the categories 1,2, 3, -1, 0) ---we should consider only once
ID Category Admit Discharge Med_taken_time
001 1 10thDEC10:00AM 12thDEC10:00AM 11DEC9AM
001 1 10thDEC10:00AM 12thDEC10:00AM 11DEC12AM
001 1 10thDEC10:00AM 12thDEC10:00AM 11thDEC03pM
001 1 10thDEC10:00AM 12thDEC10:00AM 11thDEC05pM
001 1 10thDEC10:00AM 12thDEC10:00AM 12thDEC05AM
002 -1 11thDEC10:00AM 12thDEC10:00AM 11DEC11AM
002 -1 11thDEC10:00AM 12thDEC10:00AM 11DEC12AM
002 -1 11thDEC10:00AM 12thDEC10:00AM 12thDEC10AM
002 -1 11thDEC10:00AM 12thDEC10:00AM
002 -1 11thDEC10:00AM 12thDEC10:00AM
Thanks
Hi there,
Not sure if I have fully understod but perhaps see how this goes.
Please add a column to your table
MyColumn = IF( DATEDIFF( MedTable[Med_taken_time], 'MedTable'[Discharge], HOUR)>12,1,0)
Then you can add the following Measures
Numerator = CALCULATE(SUM(MedTable[MyColumn])) Denominator = CALCULATE(DISTINCTCOUNT(MedTable[ID]))
If the measures are correct, they can be combined into a single measure using the DIVIDE function.
Thanks again Phil,
If I may ask what is the reason for using CALCULATE in the numerator and denominator calculations?
Wouldnt SUM or DISTINTCOUNT by itself give us the result?without needing to use CALCULATE !
Thanks
Hi @karkar,
You're right. If you want to add filter in the formula, you will use CALCULATE function.
In addition, do you resolve your issue? If it does, please share your solution or mark the right reply as answer, which will help more people.
Best Regards,
Angelia
Hello,
Thanks for your comment. But what is the filter in the following? MAX is the filter?
Numerator = CALCULATE(MAX(MedTable[MyColumn]))
Cant we just use the following instead of the above?:
Numerator = MAX(MedTable[MyColumn])
Thanks
There is no filter in this CALCULATE function, as @v-huizhn-msft suggested, IF you need to add filter to your calculation then you will use CALCULATE function, in this case it is not required and no filter is used.
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.
Hello Phil,
Thanks for taking time to solve the probelm. it looks like its doing the numerator calculation a different way.
Perhaps try this?
Numerator = CALCULATE(MAX(MedTable[MyColumn]))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |