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
StoryofData
Helper III
Helper III

% of Quarter on Bar Chart

Hi, I have a 'Calendar' and 'Query1' data table, I am connecting the two based on 'Calendar'[Date] to 'Query 1'[Date]
Sample Data: 
 
AttributeDateCaseNumberCaseOutcome
Date Closed1/30/2003L1-00Not Substantiated
Date Opened10/3/2002L1-00Not Substantiated
Date Closed10/22/2003L2-00Not Substantiated
Date Opened10/1/2003L2-00Not Substantiated
Date Closed1/3/2005L3-00Substantiated
Date Opened1/1/2005L3-00Substantiated


I am trying to show % of substantiated cases by quarter on a bar chart. 
StoryofData_0-1680626168842.png

It was doing a percent of grand total initially so I tried to create a measure like this: 

 
=
CALCULATE(
DIVIDE(
DISTINCTCOUNT([CaseNumber]),
FILTER('Query1',[CaseOutcome] = "Substantiated"),
DISTINCTCOUNT([CaseNumber])),ALLEXCEPT ('Calendar','Calendar'[Fiscal Year]))
 
But I am getting an error: expression refers to multiple columns. Multiple columns cannot be converted to scalar value.
What am I doing wrong?
 
 
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @StoryofData ,

 

The error message you are seeing is because the DISTINCTCOUNT function is expecting a single column as input, but you are passing it multiple columns.

You can still use your measure, but with a few changes:

 

aa =
VAR _count1 =
    CALCULATE (
        DISTINCTCOUNT ( [CaseNumber] ),
        FILTER ( 'Query1', [CaseOutcome] = "Substantiated" )
    )
VAR _count2 =
    CALCULATE (
        DISTINCTCOUNT ( [CaseNumber] ),
        ALLEXCEPT ( 'Calendar', 'Calendar'[Fiscal Year] )
    )
RETURN
    DIVIDE ( _count1, _count2 )

 

      

 

Or please try this measure, you can then change it based on your formula

Measure = var _count1=CALCULATE(DISTINCTCOUNT('Query 1'[CaseNumber]),FILTER('Query 1',[CaseOutcome]="Substantiated"))
var _count2=DISTINCTCOUNT('Query 1'[CaseOutcome])
return DIVIDE(_count1,_count2)

vstephenmsft_0-1680750740918.png

 

                                                                                                                                    

Best Regards,

Stephen Tao

 

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

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @StoryofData ,

 

The error message you are seeing is because the DISTINCTCOUNT function is expecting a single column as input, but you are passing it multiple columns.

You can still use your measure, but with a few changes:

 

aa =
VAR _count1 =
    CALCULATE (
        DISTINCTCOUNT ( [CaseNumber] ),
        FILTER ( 'Query1', [CaseOutcome] = "Substantiated" )
    )
VAR _count2 =
    CALCULATE (
        DISTINCTCOUNT ( [CaseNumber] ),
        ALLEXCEPT ( 'Calendar', 'Calendar'[Fiscal Year] )
    )
RETURN
    DIVIDE ( _count1, _count2 )

 

      

 

Or please try this measure, you can then change it based on your formula

Measure = var _count1=CALCULATE(DISTINCTCOUNT('Query 1'[CaseNumber]),FILTER('Query 1',[CaseOutcome]="Substantiated"))
var _count2=DISTINCTCOUNT('Query 1'[CaseOutcome])
return DIVIDE(_count1,_count2)

vstephenmsft_0-1680750740918.png

 

                                                                                                                                    

Best Regards,

Stephen Tao

 

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

StoryofData
Helper III
Helper III

also tried this: 

StoryofData_0-1680631357923.png

 

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.