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
nhoang
New Member

Compare Card Visual

Hi, 

 

I'm trying to do a comparison with card visual to show % of changes between YTD average # and day with option to select the day. 

 

Daily Avg $ YTD10/19/21 (Previous Day) % change
$1,078$1,008-6.5%
1 ACCEPTED SOLUTION

Hi @nhoang 

Here you need to create a measure to calculate the YTD Average which won't be filtered by your slicer.  Try "ALL" function in your code. 

My Sample:

1.png

Measures:

YTD Average = 
CALCULATE (
    DIVIDE ( SUM ( 'Table'[Value] ), DISTINCTCOUNT ( 'Table'[Date] ) ),
    FILTER ( ALL ( 'Table' ), YEAR ( 'Table'[Date] ) = YEAR ( TODAY () ) )
)
SELECT Value = SUM('Table'[Value])
% = 
VAR _DIFF = [SELECT Value] - [YTD Average]
VAR _Percentage = DIVIDE(_DIFF,[YTD Average])
RETURN
_Percentage

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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
YukiK
Impactful Individual
Impactful Individual

Can you elaborate on this? What is it that you want to accomplish here?

I have a YTD average I would like to compare to selected date amount. 

 

YTD AverageSelect Date
76981002930.3%

Hi @nhoang 

Here you need to create a measure to calculate the YTD Average which won't be filtered by your slicer.  Try "ALL" function in your code. 

My Sample:

1.png

Measures:

YTD Average = 
CALCULATE (
    DIVIDE ( SUM ( 'Table'[Value] ), DISTINCTCOUNT ( 'Table'[Date] ) ),
    FILTER ( ALL ( 'Table' ), YEAR ( 'Table'[Date] ) = YEAR ( TODAY () ) )
)
SELECT Value = SUM('Table'[Value])
% = 
VAR _DIFF = [SELECT Value] - [YTD Average]
VAR _Percentage = DIVIDE(_DIFF,[YTD Average])
RETURN
_Percentage

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

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!

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.