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
uni_student
Frequent Visitor

DAX for calculating the number of entries in the selections of a user chosen slicer

Hello,

 

I have some industrial data whch looks like this:

 

Image 1.PNG

 

Here, the source denotes the name of the alarm, the timestamp shows the exact time the alarm occured, the area shows the area of the plant from whic the alarm originated. The time range is a calculated column which acts as the category axis for the radar chart. If the alarm occurs between 1 PM and 2 PM, the time range is 1 PM - 2 PM and so on.My full dataset has alarms for the whole 24 hour period in a day.

 

I also have slicer on the page which enables the user to select the [Time Range]. Based on this selection, I want to calculate the number of alarms in the selected time ranges and create a corresponding measure i.e. a measure for the number of alarms in the time range 12:00 AM - 01:00 AM, if it is selected in the slicer, a measure for the number of alarms in the time range 2:00 AM - 3:00 AM, if selected and so on.

 

I also want to create a measure for the time ranges that have been not selected. And this should return a zero (So, there will be 24 measures for the 24 hour period).

 

I am new to DAX, so can you please guide me how to proceed with this? So far, I just have used this:

 

selected_days = CONCATENATEX(ALLSELECTED(Day[Hour]),Day[Hour],",")

But I do not know how to use this in any other thing except a card.

 

Any help will be greatly appreciated. Do I need to create a new calculated table etc?

 

1 REPLY 1
HotChilli
Super User
Super User

You don't want to create individual measures for each hour.  Let powerbi do the work.

In a simple table like you have, you can get started by dragging any field into the Values field well and changing the summarisation (from the dropdown) to be Count.  For example, in a table visualisation, drag Time Range field once and the Area field twice onto the Values well.  Set the second Area to be Count.

Your slicer will filter the data in the table.

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.

Top Solution Authors