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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Incorrect Total

Hi Guys,

I'm having incorrect Rankx Total on my measure. see screen shot &  DAX query below, When i filter on fiscal Year, The RankTotal changes to 13 which is incorrect instead of 12. 

 

Iklizo_0-1652396096582.png

 

Table Rank2 =
VAR _DivisonRanking =
IF (
NOT ISBLANK( [Percent] ),
CALCULATE (
RANKX (
FILTER ( ALL ( dim_sites[Division] ), NOT ISBLANK( [Percent] ) ),
[Percent],
,
DESC,
DENSE
),
ALL ( dim_sites[Region] ),
ALL ( dim_sites[Site_District] ),
ALL ( dim_sites[Site_Name] )
)
)
VAR _RegionRanking =
IF (
NOT ( ISBLANK( [Percent] ) ),
CALCULATE (
RANKX (
FILTER ( ALL ( dim_sites[Region] ), NOT ( ISBLANK( [Percent] ) ) ),
[Percent] ,
,
DESC,
DENSE
),
ALL ( dim_sites[Site_District] ),
ALL ( dim_sites[Site_Name] ),
ALLSELECTED ( dim_sites[Division] )
)
)
VAR _MarketRanking =
IF (
NOT ( ISBLANK( [Percent] ) ),
CALCULATE (
RANKX (
FILTER ( ALL ( dim_sites[Site_District] ), NOT ( ISBLANK( [Percent] ) ) ),
[Percent],
,
DESC,
DENSE
),
ALL ( dim_sites[Site_Name] ),
ALLSELECTED ( dim_sites[Region] ),
ALLSELECTED ( dim_sites[Division] )
)
)
VAR _SiteRanking =
IF (
NOT ( ISBLANK( [Percent] ) ),
CALCULATE (
RANKX (
FILTER ( ALL ( dim_sites[Site_Name] ), NOT ( ISBLANK( [Percent] ) ) ),
[Percent],
,
DESC,
DENSE
),
ALLSELECTED ( dim_sites[Region] ),
ALLSELECTED ( dim_sites[Site_District] ),
ALLSELECTED ( dim_sites[Division] )
)
)
VAR _Results =
SWITCH (
TRUE (),
HASONEFILTER ( dim_sites[Site_Name] ), _SiteRanking,
HASONEFILTER ( dim_sites[Site_District] ), _MarketRanking,
HASONEFILTER ( dim_sites[Region] ), _RegionRanking,
HASONEFILTER ( dim_sites[Division] ), _DivisonRanking,
BLANK ()
)
RETURN
_Results
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

You can use the HASONEVALUE() function to fix the Total incorrect

Here are the steps you can follow:

Create a measure.

Total_Incorrect =
var _table=SUMMARIZE('dim_sites','dim_sites'[Division],"_value",[Table Rank2])
return
IF(HASONEVALUE('dim_sites'[Division]),[Table Rank2],SUMX(_table,[_value]))

Result

vyangliumsft_0-1652770890183.png

 

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

You can use the HASONEVALUE() function to fix the Total incorrect

Here are the steps you can follow:

Create a measure.

Total_Incorrect =
var _table=SUMMARIZE('dim_sites','dim_sites'[Division],"_value",[Table Rank2])
return
IF(HASONEVALUE('dim_sites'[Division]),[Table Rank2],SUMX(_table,[_value]))

Result

vyangliumsft_0-1652770890183.png

 

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

Anonymous
Not applicable

@AilleryO 

Look at the DAX correctly let me know if i need to include the date dim.. or which filter context I'm missing.

AilleryO
Memorable Member
Memorable Member

Hi,

 

Do you have any blank value hidden ?

It must be related to context filters, because as soon as you are on a total (=no filter) or in a visual card (= no filter) you get 13 instead of 12. It means that your ranking without filters is incorrect.

Try to look for missing filters in your results...

Hope it helps a bit

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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