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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Chandrashekar
Resolver III
Resolver III

Tretas : Not getting count based on variable

Hello Team,

 

am trying to get count of priority am using below code but it is not working.

 

Inflow_Priority =
 
var CompanyRegionAU_Company =
Max(CompanyRegionAU[Company])
Var CompanyRegionAU_Region=
Max(CompanyRegionAU[Region])
Var queueselect_queue=
Max(Queue[Queue])
 

Var Table_join=
CROSSJOIN(
SELECTCOLUMNS({CompanyRegionAU_Company},"Name",[Value]),
SELECTCOLUMNS({CompanyRegionAU_Region},"Region",[Value]),
SELECTCOLUMNS({queueselect_queue},"Queue",[Value])
 
)
RETURN
CALCULATE(
COUNTROWS(Source),FILTER(all(Source),Source[Priority_is]=1),
TREATAS(Table_join,Source[company],Source[Region],Source[Queue])
)
Regards,
Chandrashekar B
1 ACCEPTED SOLUTION

Great!

 

Please accept the solution(s) that resolved your question in order to mark it as accepted so future readers can find it more quickly.

View solution in original post

9 REPLIES 9
AlexisOlson
Super User
Super User

The cross join construction feels odd to me.

I think I'd try writing this DAX more like this:

 

Inflow_Priority =
CALCULATE (
    COUNTROWS ( Source ),
    FILTER ( ALL ( Source ), Source[Priority_is] = 1 ),
    TREATAS (
        SUMMARIZE ( CompanyRegionAU, CompanyRegionAU[Company], CompanyRegionAU[Region] ),
        Source[company], Source[Region]
    ),
    TREATAS ( VALUES ( Queue[Queue] ), Source[Queue] )
)

 

Hello Alex,

 

I tried your solution but it is not working. I need Priority 1 and Priority 2 in different columns.

 

Regards,

Chandrashekar B

Hello Alex,

 

Sorry it is my mistake(Format issue it was text and turned to Number) and it is working now.

Great!

 

Please accept the solution(s) that resolved your question in order to mark it as accepted so future readers can find it more quickly.

Chandrashekar
Resolver III
Resolver III

Hello Team,

 

Please see attached example report Sample Report as am trying to get priority count am using below code but it is not working.

@Chandrashekar  I am guessing you are expecting this

smpa01_1-1642170432541.png

 

 

To reach the following outcome, you need two measures

_countrows =
VAR _name =
    MAX ( Table3[Name] )
VAR _location =
    MAX ( Table3[Location] )
VAR _tbl =
    CROSSJOIN (
        SELECTCOLUMNS ( { _name }, "name", [Value] ),
        SELECTCOLUMNS ( { _location }, "location", [Value] )
    )
RETURN
    CALCULATE (
        COUNTROWS ( FILTER ( Table1, Table1[Priority] = 1 ) ),
        TREATAS ( _tbl, Table1[Name], Table1[Location] )
    )



Sum = SUMX(Table3,[_countrows])

 

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hello,

 

I need to Priority1 and Pririty 2 in two different columns.

 

Regards,

Chandrashekar B

Hi, Is this your desired result?
Screenshot_5.jpg


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

Hello,

 

I need to Priority1 and Pririty 2 in two different columns.

Chandrashekar_0-1642238200991.png

 

 

Regards,

Chandrashekar B

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.