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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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