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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
jimmyhua
Helper I
Helper I

Error: cannot convert value 'CSS' of type Text to type True/False in which CSS is a division

Hi All,

 

I try to create a dax to pull top 10 projects with backlogs by division and by month.  below is the dax.  I got an error message saying cannot convert Division name to T/F logic.  what could be wrong?

VAR DivisionMonthTable =
   
    ADDCOLUMNS(
    SUMMARIZE(
        PJ401,
        PJ401[Div Name],
        PJ401[Date],
        PJ401[Project ID],
        PJ401[Project Name],
        "Backlog", CALCULATE(SUMX(PJ401, [CM CV]*[CV%]-[Inception-to-date Revenue       ]), KEEPFILTERS( PJ401[Div Name]),KEEPFILTERS( PJ401[Date]))
    ),
        "RankByBL",
            RANKX(
               All(PJ401[Project ID]),
                [Backlog],
                ,
                DESC,
                Dense
            )
        )
        RETURN
        FILTER(
        DivisionMonthTable,
        [RankByBL] <= 10
    )
1 ACCEPTED SOLUTION

Hi @jimmyhua ,

Sorry, I forgot to mention that “multiple columns cannot be scalar value” indicates that the measure returns a table. Normally a measure should return a single value.

'Filter' is a table function that returns a table:

 

RETURN
    FILTER ( DivisionMonthTable2, [RankByBL] <= 10 )

 

If you want to dynamically rank by Department and Date, I think you need to create two slicers and use the Card visual.

This function can combine the table into a single value

CONCATENATEX function (DAX) - DAX | Microsoft Learn

 

VAR DivisionMonthTable =
    SUMMARIZE (
        PJ401,
        PJ401[Div Name],
        PJ401[Date],
        PJ401[Project ID],
        PJ401[Project Name],
        "Backlog",
            CALCULATE (
                SUMX ( PJ401, [CM CV] * [CV%] - [Inception-to-date Revenue] ),
                KEEPFILTERS ( PJ401[Date] )
            )
    )
VAR DivisionMonthTable2 =
    ADDCOLUMNS (
        DivisionMonthTable,
        "RankByBL", RANKX ( DivisionMonthTable, [Backlog],, DESC, DENSE )
    )
RETURN
    CONCATENATEX (
        FILTER ( DivisionMonthTable2, [RankByBL] <= 10 ),
        [Div Name] & " " & [Date] & " " & [Project ID] & " " & [Project Name] & " " & [RankByBL],
        UNICHAR ( 10 )
    )

 

This result should change dynamically based on the slicer selection.

Something like this:

vzhouwenmsft_0-1731379703858.png

vzhouwenmsft_1-1731379723928.png

If you still have problems, please provide simple data or a .pbix file without sensitive data.

If you are unsure how to upload data please refer to

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,
Wenbin Zhou

 

 

View solution in original post

6 REPLIES 6
Rupak_bi
Post Prodigy
Post Prodigy

HI @jimmyhua 
please share sample data and desired output for better understanding and tested solution.



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/
BeaBF
Memorable Member
Memorable Member

@jimmyhua Hi! Try with:

VAR DivisionMonthTable =
ADDCOLUMNS(
SUMMARIZE(
PJ401,
PJ401[Div Name],
PJ401[Date],
PJ401[Project ID],
PJ401[Project Name],
"Backlog",
CALCULATE(
SUMX(PJ401, [CM CV]*[CV%] - [Inception-to-date Revenue]),
KEEPFILTERS(PJ401[Date])
)
),
"RankByBL",
RANKX(
FILTER(
ALL(PJ401),
PJ401[Div Name] = EARLIER(PJ401[Div Name]) && PJ401[Date] = EARLIER(PJ401[Date])
),
[Backlog],
,
DESC,
Dense
)
)
RETURN
FILTER(
DivisionMonthTable,
[RankByBL] <= 10
)

 

BBF

Hi BeaBF,

 

Thank you very much.  I tried. It got rid of the error.  but the ranking seems off.  all projects get a ranking of 1 and the result is the Sum of all projects.  do i need to put in a keepfilter somewhere?  Really appreciated your help.

Hi all,thanks for the quick reply, I'll add more.

Hi @jimmyhua ,

Try this:

VAR DivisionMonthTable =
    SUMMARIZE (
        PJ401,
        PJ401[Div Name],
        PJ401[Date],
        PJ401[Project ID],
        PJ401[Project Name],
        "Backlog",
            CALCULATE (
                SUMX ( PJ401, [CM CV] * [CV%] - [Inception-to-date Revenue] ),
                KEEPFILTERS ( PJ401[Date] )
            )
    )
VAR DivisionMonthTable2 =
    ADDCOLUMNS (
        DivisionMonthTable,
        "RankByBL", RANKX ( DivisionMonthTable, [Backlog],, DESC, DENSE )
    )
RETURN
    FILTER ( DivisionMonthTable2, [RankByBL] <= 10 )

 

Best Regards,
Wenbin Zhou

@v-zhouwen-msft  really appreciated.  your solution gives me a table of ranked top 10 by entire organization across all time period.  I actually need top 10 result by month, by division.  if no division is selected, then by the entire organization.  I tried break the code in to different sections ( division or total organization).  but then try to conditionally select which table to use based on external filter, it gives me an error message on multiple columns cannot be scalar value.  apparently I cannot apply if or switch to a table.  so I am still stuck.  thanks again for helping.

Hi @jimmyhua ,

Sorry, I forgot to mention that “multiple columns cannot be scalar value” indicates that the measure returns a table. Normally a measure should return a single value.

'Filter' is a table function that returns a table:

 

RETURN
    FILTER ( DivisionMonthTable2, [RankByBL] <= 10 )

 

If you want to dynamically rank by Department and Date, I think you need to create two slicers and use the Card visual.

This function can combine the table into a single value

CONCATENATEX function (DAX) - DAX | Microsoft Learn

 

VAR DivisionMonthTable =
    SUMMARIZE (
        PJ401,
        PJ401[Div Name],
        PJ401[Date],
        PJ401[Project ID],
        PJ401[Project Name],
        "Backlog",
            CALCULATE (
                SUMX ( PJ401, [CM CV] * [CV%] - [Inception-to-date Revenue] ),
                KEEPFILTERS ( PJ401[Date] )
            )
    )
VAR DivisionMonthTable2 =
    ADDCOLUMNS (
        DivisionMonthTable,
        "RankByBL", RANKX ( DivisionMonthTable, [Backlog],, DESC, DENSE )
    )
RETURN
    CONCATENATEX (
        FILTER ( DivisionMonthTable2, [RankByBL] <= 10 ),
        [Div Name] & " " & [Date] & " " & [Project ID] & " " & [Project Name] & " " & [RankByBL],
        UNICHAR ( 10 )
    )

 

This result should change dynamically based on the slicer selection.

Something like this:

vzhouwenmsft_0-1731379703858.png

vzhouwenmsft_1-1731379723928.png

If you still have problems, please provide simple data or a .pbix file without sensitive data.

If you are unsure how to upload data please refer to

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,
Wenbin Zhou

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.