Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

Filtering from MySQL database

Hi all,

 

I'm really new to PowerBI, but I'm creating a dashboard for the real estate company where I work to check our current apartment occupancy. All of our bookings go through our website, so all of our apartments have a 'status' column in the database. This column either says 0 (available), 1 (in option) or 2 (rented out). 

 

I'm trying to use the gauge visualization to check how many apartments have 'status' = 2 as the value (using COUNT in the visualization fields), with the maximum value being the COUNT of rows in the database. However, because I'm filtering the apartments with 'status' = 2, Power BI only counts the rows where 'status' = 2 for the maximum value. This results in being the value and the maximum value to be equal to eachother. 

 

Does anyone know how I can fix this? I've tried searching on the forums already, without any luck unfortunately...

4 REPLIES 4
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could use two measures to show the result.

CurrentCount =
CALCULATE (
    COUNT ( 'Table'[apartmentno] ),
    FILTER ( 'Table', 'Table'[status] = 2 )
)
AllCount = 
COUNT('Table'[apartmentno])

When the database data is updated, you could click update button to refresh data. The measure will return the latest result.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

Hi @v-eachen-msft, thanks for the help.

 

May I ask how I create two seperate measures? See the screenshot below on how I have my data filtered right now:

49fb94e960aa2474520fbfc01b4bb7e3.png

 

 

 

 

 

 

 

 

 

 

 

Count of apartmentid should be somewhere around 285, but because on the filter on status, it only counts the apartmentid's with status = 2.

I hope you'll be able to help 🙂


Edit: fiddled around with measures and figured it out using the measures @v-eachen-msft provided 🙂

parry2k
Super User
Super User

@Anonymous You question is clear but not sure what is your expected result. share sample data and expected output, it will help to get you the solution. 



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.

Anonymous
Not applicable

@parry2k Will do! I will provide some small dummy data.

 

So I have my apartments table in my MySQL database:

apartmentnostatus
1.02
1.11
1.22
1.32
1.40
1.50

 

In the example above, there are three 'rented out' apartments, two 'available' apartments and one 'in option' apartment, which makes for a total of six apartments.

 

In my gauge, I want the minimum value to be 0 (which is default), the maximum value to be 6 (the total apartments) and the (current?) value to be 3. I could manually set the maximum value to 6, but I'd like this value to be dynamic, since we are expected to rent out more apartments in the near future. When adding these apartments to our website, the maximum value would then automatically be updated out of the database.

 

I hope my expected result is more clear now 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.