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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
cristianml
Post Prodigy
Post Prodigy

HASONEVALUE CALCULATE COLUMN SUMX

Hi,

I need help with the following measure.

 

 

NWD_2 =
VAR REV = 'Revenue - CCI'[Rev Current Quarter]
VAR NWD = 'Revenue - CCI'[NWD Value]
VAR NWD_2 = IF(REV=BLANK() && NWD>0,BLANK(),NWD)
RETURN
IF(HASONEVALUE('00_CALENDAR'[FY & Q]),NWD_2,SUMX(VALUES('00_CALENDAR'[FY & Q]),NWD_2))

 

I need to the result of 36.2 (sum of 16.9 + 19.3)  instead of what is given in the red circle.     

cristianml_1-1646405124888.png

Not sure why HASONEVALUE is not working in this case.

 

Coudl you help me to correct the issue ?

 

Thanks !

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @cristianml ,

You can try to modify dax as follows:

NWD_2 =
IF(
HASONEVALUE('00_CALENDAR'[FY & Q]),
Sumx(
Values('00_CALENDAR'[FY & Q]),
IF([Rev Current Quarter]>0 && [NWD Value]>0, [NWD Value],blank()),
Blank())

Or You can create a measure.

Sum_Total =
VAR _table =
    SUMMARIZE ( '00_CALENDAR', '00_CALENDAR'[FY & Q], "_value", [ NWD_2] )
RETURN
    IF ( HASONEVALUE ( '00_CALENDAR'[FY & Q] ), [NWD_2], SUMX ( _table, [_value] ) 

 

Best Regards,

Liu Yang

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

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @cristianml ,

You can try to modify dax as follows:

NWD_2 =
IF(
HASONEVALUE('00_CALENDAR'[FY & Q]),
Sumx(
Values('00_CALENDAR'[FY & Q]),
IF([Rev Current Quarter]>0 && [NWD Value]>0, [NWD Value],blank()),
Blank())

Or You can create a measure.

Sum_Total =
VAR _table =
    SUMMARIZE ( '00_CALENDAR', '00_CALENDAR'[FY & Q], "_value", [ NWD_2] )
RETURN
    IF ( HASONEVALUE ( '00_CALENDAR'[FY & Q] ), [NWD_2], SUMX ( _table, [_value] ) 

 

Best Regards,

Liu Yang

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

littlemojopuppy
Community Champion
Community Champion

@cristianml can you provide some sample data to work with?

Hello @littlemojopuppy ,

The HASONEVALUE is a very simple dax which returns TRUE when the context for column Name has been filtered to one distinct value only. Otherwise is FALSE.

Syntax: HASONEVALUE(<ColumnName>)
Parameter: It passes the name of an existing column. It cannot be an expression.

Return value : Boolean TRUE/FALSE

You can get the sample data and pbix from the below video in the description/comment section

Hope this helps!

Usage of Hasonevalue DAX Function  

@powerbi_zone I'm not sure why this is directed to me, but it certainly seems like a commercial for something...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.