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
vissvess
Helper V
Helper V

DAX function returns blank in card

Hi,

 

Could anyone please clarify why the following measure returns "Blank".

 

Running chassis matching with F =
VAR overallmax = [Overall max pallet positions per 3hr bucket]
VAR maxpalletoccuredday =
    CALCULATE (
        MAX ( 'Calendar'[Date] ),
        FILTER (
            VALUES ( 'Calendar'[Date] ),
            [Max Pallet positions per day] = overallmax
        )
    )
VAR maxpalletoccuredbucket =
    CALCULATE (
        MAX ( 'Time Buckets'[Bucket] ),
        FILTER (
            VALUES ( 'Time Buckets'[Bucket] ),
            [New Pallet requirement] = overallmax
        )
    )
RETURN
    maxpalletoccuredbucket

 

I doubt that, the max worked for date. But the second time, the max is applied on data type text.

I am not sure that max fits in here. Could anyone lists the dax function that results a single value similar to max but not arithmatic function.

Thanks

7 REPLIES 7
Anonymous
Not applicable

Running chassis matching with F =
VAR __overallMax = [Overall max pallet positions per 3hr bucket]
VAR __maxPalletOccuredBucket =
    FILTER (
        VALUES ( 'Time Buckets'[Bucket] ),
        [New Pallet requirement] = __overallMax
    )
RETURN
    __maxPalletOccuredBucket

You can try the above but since I can't see the model, don't know the measures used and don't really know what the code does in the context you try to use it in, I can't be of more help. FILTER should return one value. If it returns more, then you'll get an error.

 

Best

Darek

Dear @Anonymous ,

 

The code worked great. As mentioned by you. There is a one time occurance of the max value. So the code doesnot returned an error. 

 

But could you please clarify, what to do if I get an error in future as the dataset may get updated, so that there are two field values with the max. What to do to get the any one or latest or both in the list that to be used for slicer.

 

Please extend your kind help further.

 

Thanks

Anonymous
Not applicable

If you get 2+ time buckets, then you have to decide what rule you want to apply to get one of them as the value of your measure. It's your choice. I can't help you with this. All I can do is try to figure out how to implement rules and algorithms. I can't create them for you.

Best
Darek

Hi @Anonymous ,

 

You are correct. The logic should be mine. I need the max value with latest date.

 

Kindly suggest to improve the code.

 

Thanks

VissVess

Anonymous
Not applicable

Maybe this could work? I'm not sure since I don't know all the details of the model.

 

Running chassis matching with F =
VAR __overallMax = [Overall max pallet positions per 3hr bucket]
VAR __maxDate =
    MAXX (
        FILTER (
            VALUES ( 'Calendar'[Date] ),
            [Max Pallet positions per day] = overallmax
        ),
        'Calendar'[Date]
    )
VAR __maxPalletOccuredBucket =
    CALCULATE(
        VALUES ( 'Time Buckets'[Bucket] ),
        FILTER (
        	VALUES ( 'Time Buckets'[Bucket] ),
        	[New Pallet requirement] = __overallMax
        ),
        'Calendar'[Date] = __maxDate
    )
RETURN
    __maxPalletOccuredBucket

Best

Darek

Mariusz
Community Champion
Community Champion

Hi @vissvess 

 

Can you create a data sample that represents your requierment and use this sample to show the desired outcome?

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski


 

vissvess
Helper V
Helper V

In short, I am in need of finding the value that corresponds to max value of a measure.

 

In detail,

 

I have a measure which returns a particular value.
I want to get the particular field value which corresponds to the max of measure output.

 

I am not well in dax. So, feel free to neglect my code in case and propose new code.

 

Any help would be so thankful.

 

Thanks in advance.

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.