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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Learner_SG
Helper IV
Helper IV

Select the 4 highest time for the last 7th and 6th day and evenly distributed.

Hi ,

I have a requirement  whereby I need to select the 4 highest usage timings based on the last 6th and 7th day and provide a recommendation cleaning schedule. In my previous approach, it selected the 4 highest values and it could be timings neasrby(8AM,9,10,11AM) which should not how it be. It should be evenly distirbuted between 7AM -10PM. So now I need to rewrite the DAX .COuld anyone help.Thanks.I will explain below how I had done previously.

 

I have a measure to select the last 6th and 7th day 

Learner_SG_0-1652748974375.png

I have another measure to select the sum of the water consumption and filter for the last 6th and 7th day and also select only between 7 to 10 PM.

Learner_SG_1-1652751305153.png

 

The next rank_measure is placed in the filter and selected <=4 to select 4 highest values.

and the correspoinding time and day is shown in the table.

Learner_SG_2-1652751386913.png

 

Learner_SG_3-1652751417426.png

 

So the above table is the final output. here it can be seen that the timings are close which does not fit the purpose as the cleaning schedulte recommendation should not be close..

thanks in advance if someone could help me on this matter.

 

 

 

1 ACCEPTED SOLUTION

Hi, @Learner_SG 

 

You can try the following methods.

Column:

Column = 
IF (
    [Intervals] = BLANK (),
    BLANK (),
    IF (
        [sum_wc_consumption]
            = CALCULATE (
                MAX ( measurement[sum_wc_consumption] ),
                FILTER (
                    measurement,
                    [Intervals] = EARLIER ( measurement[Intervals] )
                        && [weekday] = EARLIER ( measurement[weekday] )
                )
            ),
        [Time:]
    )
)

vzhangti_1-1652944447942.png

Is this the result you expect? For each time period, choose a time that is used most frequently.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. Avoid posting screenshots of your source data if possible.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Hi @lbendlin ,sorry for the screenshots alone. I have attached the sample data . this is the summarized table which I created from the original table and I need to select the highlighted values(time and day) which has to be shown in a table. This will serve as my recommendation table.

https://docs.google.com/spreadsheets/d/13j1zsIoI9CMrGhfMHV9aMfSVcRT9lgVy/edit?usp=sharing&ouid=10671...

Thank you for providing the sample data. That helps a lot with proposing a potential solution.

Here is a graphical version using a heatmap:

 

lbendlin_0-1652898615723.png

That might be sufficient?

@lbendlin ,thanks. But what I need is the time and weekday to be selected and present it in a table. So the highest from each interval , 7-10 ,12-2,4-6 8-10pm 1 each should be selected and the corresponding time and day should be shown in my table. Hope my explanation is clear. Please let me know if you need further clarification.

Hi, @Learner_SG 

 

You can try the following methods.

Column:

Column = 
IF (
    [Intervals] = BLANK (),
    BLANK (),
    IF (
        [sum_wc_consumption]
            = CALCULATE (
                MAX ( measurement[sum_wc_consumption] ),
                FILTER (
                    measurement,
                    [Intervals] = EARLIER ( measurement[Intervals] )
                        && [weekday] = EARLIER ( measurement[weekday] )
                )
            ),
        [Time:]
    )
)

vzhangti_1-1652944447942.png

Is this the result you expect? For each time period, choose a time that is used most frequently.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-zhangti ,this is what I expected .But a minor issue that I am facing now when I used for expression is that it selects the blank value into the table as shown below. How can I exclude it out. I could not find a way to filter it out as It is a time value.

Learner_SG_0-1652947160010.png

 

Hi, @Learner_SG 

 

As in the example shown, you can leave the blank value unchecked.

vzhangti_0-1652947439183.png

vzhangti_1-1652947494634.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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