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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
cpoojan
Regular Visitor

How to return value from CROSSJOIN

Hi All BI Expert. 

       I'm working on generating a system usage report. There are 2 table 
1. M_User table is a master table for all user

2. Log table is a report that shows the number of people who log-in to use this system. 

      My challenge is to show people who didn't use the system in Powerbi as Table Visualization.

For example

 

 M_User

Emp ID | Emp_Name
0001             A
0002             B
0003             C

 

LOG

LoginDatte      |  EmpID   |  Name
2021-02-01         0001          A
2021-02-01         0002          B
2021-02-02         0001          A
2021-02-02         0003          C

 

I'd like to get this result 


LoginDate     | Emp_ID   |   Name  | Measure 

2021-02-01       0001           A            1

2021-02-01       0002           B            1

2021-02-01       0003           C            0

2021-02-02       0001           A            1

2021-02-02       0002           B             0

2021-02-02       0003           C            1

 

The measure can be any other variable name I may use as Yes/No. I can adapt later. 

 

Someone has told me about CROSSJOIN concept but I'm new to DAX. Thank you in advance. 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@cpoojan 

Create a table named "Usage" from the New Table option as follows:

Fowmy_0-1622106942643.png
Add the Fields to a table visual fro the Usage table and create the following measure:

Measure = 
IF( 
    CONTAINS('Log','Log'[EmpID],MAX(Usage[Emp ID]),'Log'[LoginDate],MAX(Usage[LoginDate])),
    "Yes",
    "No"
)

Result

Fowmy_1-1622107019699.png

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

let
    M_User = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjAwMFTSUXJUitUBc4yAHCcYxxjIcVaKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Emp ID" = _t, Name = _t]),
    Log = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1MNI1MFTSUTIwAFOOSrE6mDJGQMoJVcYIpx6ojDGQclaKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [LoginDate = _t, EmpID = _t, Name = _t]),
    Cartesian = let rs=Table.ToRows(M_User) in Table.FromRows(List.TransformMany(List.Distinct(Log[LoginDate]), each rs, (x,y)=>{x}&y), {"Date","Emp ID","Name"}),
    #"Nested Join" = Table.NestedJoin(Cartesian, {"Date","Emp ID"}, Log, {"LoginDate","EmpID"}, "Count", JoinKind.LeftOuter),
    Count = Table.TransformColumns(#"Nested Join", {"Count", Table.RowCount})
in
    Count

Screenshot 2021-05-27 124217.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Fowmy
Super User
Super User

@cpoojan 

Create a table named "Usage" from the New Table option as follows:

Fowmy_0-1622106942643.png
Add the Fields to a table visual fro the Usage table and create the following measure:

Measure = 
IF( 
    CONTAINS('Log','Log'[EmpID],MAX(Usage[Emp ID]),'Log'[LoginDate],MAX(Usage[LoginDate])),
    "Yes",
    "No"
)

Result

Fowmy_1-1622107019699.png

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you so much. Let me try.

Helpful resources

Announcements
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.

Top Solution Authors